iGeek Blog

Jignesh Patel's Blog

categories

recent posts

recent comments



This is much needed when you want to force the web browser to show the Save File dialog box. Generally the web browser opens the file which can be read by it.

It all depends on the header which is being sent from the web server to the client browser. By default, the browser can open the images i.e. .gif, j.pg, .png & some other file as well like .swf (for FF especially).

This is how it can be implemented with Content-disposition. For example I want to force to save the .swf file.

The PHP code will be:


<?php
header('Content-disposition: attachment; filename=filename.swf');
header('Content-type:application/x-shockwave-flash');
readfile('pathoffile/filename.swf');
exit;
?>

0 comments

Post a Comment