Re: [PHP] [PHP Header] Right-Click Download in Firefox showing php filename
On 8/3/08, Will [EMAIL PROTECTED] wrote: @readfile($filename); You should look into a webserver and instead of using readfile() which will keep the PHP engine open while it is spoonfeeding the browser, offload the file to the webserver. nginx has X-Accel-Redirect (nginx is the best anyway) Lighttpd has X-Lighttpd-Sendfile (or something) Apache has mod_sendfile (something like that) etc. I don't think it will change the renaming behavior, but it will offload your PHP engines for normal processing. :) Basically (you'll have to configure it quick but otherwise) instead of the readfile($file) you'd be sending another: header(X-Accel-Redirect: $file); (you have to configure $file's location) and that's it. the webserver takes over and PHP is released back to do other things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP Header] Right-Click Download in Firefox showing php filename
2008/8/4 Will [EMAIL PROTECTED]: I am trying to have users download a file named 'Setup.msi', however under a PHP file with the sent header information, the default name to $forcename = ApplicationSetup_v1_0.msi; $filename = Setup.msi; header(Content-Type: application/force-download); header(Content-Type: application/octet-stream; name=.$forcename); header(Content-Type: application/octetstream; name=.$forcename); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($filename)); @readfile($filename); Try a variation on this: header(Content-Type: application/x-msi); header(Content-Disposition: attachment; filename=\ApplicationSetup_v1_0.msi\; ); header(Content-Transfer-Encoding: binary); header(Content-Length: . filesize('Setup.msi')); readfile('Setup.msi'); http://www.mhonarc.org/~ehood/MIME/rfc2183.txt content-disposition controls what the browser should do with the file you're sending (open it or save it). filename suggests what the file should be saved as on the local system, when downloading as an attachment content-type is the mime-type of the file you're sending -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP Header] Right-Click Download in Firefox showing php filename
Thanks everyone. I looked into the Firefox browser forums/support and found that the Right-Click Save Link As does not send the header response, as it will take the file as-is. So in this example, it sees the 'download.php' and then takes that as the default name. It then starts the download of the file, which in turn gets the header information and starts downloading the 'Setup.msi'... but now under the name of 'download.php' -- Again to note in IE the Right-Click will get the header information including the Content-Disposition and THEN open the Save As window. In all browsers, the Left-Click works as normal as it processes the header information. My solution: With mod_rewrite under Apache. I know rewrite the 'download.php' file as default of 'ApplicationSetup.msi' -- So IF Right-Clicked in FF, the user defaults the link with the proper extension to Save As. Otherwise if Left-Clicked, the rewrite will run the 'download.php' and then prompt with the correct MSI with version number (as intended) : 'ApplicationSetup_v1_0.msi' Otherwise with all the other header information, it works fine.. its just the browsers that DO NOT get the header info on a Right-Click Save As on objects, as they prompt to save in location BEFORE header info is sought. William Frankhouser WilzDezign On Mon, Aug 4, 2008 at 2:40 AM, David Otton [EMAIL PROTECTED] wrote: 2008/8/4 Will [EMAIL PROTECTED]: I am trying to have users download a file named 'Setup.msi', however under a PHP file with the sent header information, the default name to $forcename = ApplicationSetup_v1_0.msi; $filename = Setup.msi; header(Content-Type: application/force-download); header(Content-Type: application/octet-stream; name=.$forcename); header(Content-Type: application/octetstream; name=.$forcename); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($filename)); @readfile($filename); Try a variation on this: header(Content-Type: application/x-msi); header(Content-Disposition: attachment; filename=\ApplicationSetup_v1_0.msi\; ); header(Content-Transfer-Encoding: binary); header(Content-Length: . filesize('Setup.msi')); readfile('Setup.msi'); http://www.mhonarc.org/~ehood/MIME/rfc2183.txt content-disposition controls what the browser should do with the file you're sending (open it or save it). filename suggests what the file should be saved as on the local system, when downloading as an attachment content-type is the mime-type of the file you're sending -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [PHP Header] Right-Click Download in Firefox showing php filename
I followed some of the examples that was on PHP header() http://us3.php.net/manual/en/function.header.php I am trying to have users download a file named 'Setup.msi', however under a PHP file with the sent header information, the default name to the user will be 'ApplicationSetup_v1_0.msi' -- I am sending the recommended header information in the notes. For example in my 'download.php': $forcename = ApplicationSetup_v1_0.msi; $filename = Setup.msi; header(Content-Type: application/force-download); header(Content-Type: application/octet-stream; name=.$forcename); header(Content-Type: application/octetstream; name=.$forcename); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($filename)); @readfile($filename); When I LEFT-CLICK the 'download.php' link in Internet Explorer 6/7 and Firefox 2/3, it defaults the download name to the variable that I want it changed to ($forcename). When I RIGHT-CLICK in Internet Explorer 6/7, it also works. However when I RIGHT-CLICK the link in Firefox 2/3, it downloads the file as 'download.php' and not the specified name and .msi extension (I can still rename to the .msi extension and it works fine). Am I missing another header or is there known issue for Firefox right-click Save Link As... and default the name to something else? Or should I contact Firefox on this to get more information to default the name to something different? Thanks -- William Frankhouser WilzDezign http://www.wilzdezign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php