[PHP] File download question
Hi Everyone, I've setup a filedownload which works but i'm having an issue, i've left out but when it downloads it, while it has the correct file it doesn't have a file extension associated with it, I need the .7z extension associated with the filename, can anyone see why that would do this below? I'm sure it's something obvious but i'm new to doing file downloads. Thank you everyone Chris $file = SOMEFILE.7Z; $speed = 60; // i.e. 60 kb/s download rate if(file_exists($file) is_file($file)) { header(Cache-control: private); header(Content-Type: application/octet-stream); header(Content-Length: .filesize($file)); header(Content-Disposition: filename=$file . %20); flush(); $fd = fopen($file, r); while(!feof($fd)) { echo fread($fd, round($speed*1024)); // $speed kb at a time flush(); sleep(1); } fclose ($fd); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download question
I think that your problem in this line: header(Content-Disposition: filename=$file . %20); I don't know what that %20 is for and you should quote the filename, that line should be something like this: header(Content-Disposition: attachment; filename=\$file\); Considering that $filename already has the 7z extension. Jonathan On Sun, Sep 6, 2009 at 3:19 PM, Chris Paynechris_pa...@danmangames.com wrote: Hi Everyone, I've setup a filedownload which works but i'm having an issue, i've left out but when it downloads it, while it has the correct file it doesn't have a file extension associated with it, I need the .7z extension associated with the filename, can anyone see why that would do this below? I'm sure it's something obvious but i'm new to doing file downloads. Thank you everyone Chris $file = SOMEFILE.7Z; $speed = 60; // i.e. 60 kb/s download rate if(file_exists($file) is_file($file)) { header(Cache-control: private); header(Content-Type: application/octet-stream); header(Content-Length: .filesize($file)); header(Content-Disposition: filename=$file . %20); flush(); $fd = fopen($file, r); while(!feof($fd)) { echo fread($fd, round($speed*1024)); // $speed kb at a time flush(); sleep(1); } fclose ($fd); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File download question
That is for IE and its silly FileName[N] rather than FileName here a good old function to download: http://www.devpro.it/code/72.html Regards Date: Sun, 6 Sep 2009 15:43:27 -0300 From: tapi...@gmail.com To: chris_pa...@danmangames.com CC: php-general@lists.php.net Subject: Re: [PHP] File download question I think that your problem in this line: header(Content-Disposition: filename=$file . %20); I don't know what that %20 is for and you should quote the filename, that line should be something like this: header(Content-Disposition: attachment; filename=\$file\); Considering that $filename already has the 7z extension. Jonathan On Sun, Sep 6, 2009 at 3:19 PM, Chris Paynechris_pa...@danmangames.com wrote: Hi Everyone, I've setup a filedownload which works but i'm having an issue, i've left out but when it downloads it, while it has the correct file it doesn't have a file extension associated with it, I need the .7z extension associated with the filename, can anyone see why that would do this below? I'm sure it's something obvious but i'm new to doing file downloads. Thank you everyone Chris $file = SOMEFILE.7Z; $speed = 60; // i.e. 60 kb/s download rate if(file_exists($file) is_file($file)) { header(Cache-control: private); header(Content-Type: application/octet-stream); header(Content-Length: .filesize($file)); header(Content-Disposition: filename=$file . %20); flush(); $fd = fopen($file, r); while(!feof($fd)) { echo fread($fd, round($speed*1024)); // $speed kb at a time flush(); sleep(1); } fclose ($fd); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
Re: [PHP] File download problem
I checked the files with an HEX editor, and I found that each downloaded file starts with EFBBBF, and after those three bytes follows the regular file. If I delete those three bytes, I can open the files just fine. Now the question is: Why do I get those three extra bytes at the beginning of each file I download with my script? Thanks Stefano Stefano Noffke wrote: Hi, Thank you for your reply. I tried your code, but the problem remains. I still can download PDF, TXT, and MP3 fine, but the ODT, DOC, and JPG are still corrupted. I wonder why it works with some files and not with others... Stefano Ashley Sheridan ha scritto: Hi Stefano, You can use this code instead to read in the file and output it to the browser, as it is binary safe. I've used it for the same reason you require, and it works fine with video clips. $fp = fopen($path, rb); while(!feof($fp)) { print(fread($fp, 1024)); flush($fp); } fclose($fp); exit(); The rb in the fopen function instructs PHP to open the file for reading in a binary safe manner. Hope this helps. Ash www.ashleysheridan.co.uk Oggetto: [PHP] File download problem Da: Stefano Noffke [EMAIL PROTECTED] Data: Mon, 18 Aug 2008 16:01:22 +0200 A: php-general@lists.php.net A: php-general@lists.php.net Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
I had a similar problem with a script I was using to stream video clips to a user from a directory that was not accessible through the web. Turned out I had already sent some HTML content down to the browser without realising it. I'll go out on a limb here and guess that those three bytes you're seeing are always the same three? If so, it's highly likely you are sending some content to the browser ahead of the file, which gets added to the beginning of the file. Ash www.ashleysheridan.co.uk ---BeginMessage--- I checked the files with an HEX editor, and I found that each downloaded file starts with EFBBBF, and after those three bytes follows the regular file. If I delete those three bytes, I can open the files just fine. Now the question is: Why do I get those three extra bytes at the beginning of each file I download with my script? Thanks Stefano Stefano Noffke wrote: Hi, Thank you for your reply. I tried your code, but the problem remains. I still can download PDF, TXT, and MP3 fine, but the ODT, DOC, and JPG are still corrupted. I wonder why it works with some files and not with others... Stefano Ashley Sheridan ha scritto: Hi Stefano, You can use this code instead to read in the file and output it to the browser, as it is binary safe. I've used it for the same reason you require, and it works fine with video clips. $fp = fopen($path, rb); while(!feof($fp)) { print(fread($fp, 1024)); flush($fp); } fclose($fp); exit(); The rb in the fopen function instructs PHP to open the file for reading in a binary safe manner. Hope this helps. Ash www.ashleysheridan.co.uk Oggetto: [PHP] File download problem Da: Stefano Noffke [EMAIL PROTECTED] Data: Mon, 18 Aug 2008 16:01:22 +0200 A: php-general@lists.php.net A: php-general@lists.php.net Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
Thanks for the reply. I think I found the problem here: The php file was saved with UTF-8 encoding, and for some unknown reason it was adding the UTF-8 BOM to the output as well. I just saved the PHP file as ANSI, and it worked like a charm. Thank you for all your help :) Stefano Ashley Sheridan wrote: I had a similar problem with a script I was using to stream video clips to a user from a directory that was not accessible through the web. Turned out I had already sent some HTML content down to the browser without realising it. I'll go out on a limb here and guess that those three bytes you're seeing are always the same three? If so, it's highly likely you are sending some content to the browser ahead of the file, which gets added to the beginning of the file. Ash www.ashleysheridan.co.uk Subject: Re: [PHP] File download problem From: Stefano Noffke [EMAIL PROTECTED] Date: Tue, 19 Aug 2008 15:17:25 +0200 To: php-general@lists.php.net To: php-general@lists.php.net I checked the files with an HEX editor, and I found that each downloaded file starts with EFBBBF, and after those three bytes follows the regular file. If I delete those three bytes, I can open the files just fine. Now the question is: Why do I get those three extra bytes at the beginning of each file I download with my script? Thanks Stefano Stefano Noffke wrote: Hi, Thank you for your reply. I tried your code, but the problem remains. I still can download PDF, TXT, and MP3 fine, but the ODT, DOC, and JPG are still corrupted. I wonder why it works with some files and not with others... Stefano Ashley Sheridan ha scritto: Hi Stefano, You can use this code instead to read in the file and output it to the browser, as it is binary safe. I've used it for the same reason you require, and it works fine with video clips. $fp = fopen($path, rb); while(!feof($fp)) { print(fread($fp, 1024)); flush($fp); } fclose($fp); exit(); The rb in the fopen function instructs PHP to open the file for reading in a binary safe manner. Hope this helps. Ash www.ashleysheridan.co.uk Oggetto: [PHP] File download problem Da: Stefano Noffke [EMAIL PROTECTED] Data: Mon, 18 Aug 2008 16:01:22 +0200 A: php-general@lists.php.net A: php-general@lists.php.net Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
I just add this comment for reference. I found this bug report on the PHP Web site: http://bugs.php.net/bug.php?id=22108 That bug explains everything :) Stefano Stefano Noffke wrote: Thanks for the reply. I think I found the problem here: The php file was saved with UTF-8 encoding, and for some unknown reason it was adding the UTF-8 BOM to the output as well. I just saved the PHP file as ANSI, and it worked like a charm. Thank you for all your help :) Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
That bug report makes sense now, in light of your problem. It wasn't something I'd ever seen happen before, as most of my work is done on Linux, and the bug seems to be specific to the way Windows uses the BOM for UTF-8 PHP files. Ash www.ashleysheridan.co.uk ---BeginMessage--- I just add this comment for reference. I found this bug report on the PHP Web site: http://bugs.php.net/bug.php?id=22108 That bug explains everything :) Stefano Stefano Noffke wrote: Thanks for the reply. I think I found the problem here: The php file was saved with UTF-8 encoding, and for some unknown reason it was adding the UTF-8 BOM to the output as well. I just saved the PHP file as ANSI, and it worked like a charm. Thank you for all your help :) Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
At 3:32 PM +0100 8/19/08, Ashley Sheridan wrote: That bug report makes sense now, in light of your problem. It wasn't something I'd ever seen happen before, as most of my work is done on Linux, and the bug seems to be specific to the way Windows uses the BOM for UTF-8 PHP files. Ash: A problem with windoezs -- that can't be! :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download problem
Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
Hi Stefano, You can use this code instead to read in the file and output it to the browser, as it is binary safe. I've used it for the same reason you require, and it works fine with video clips. $fp = fopen($path, rb); while(!feof($fp)) { print(fread($fp, 1024)); flush($fp); } fclose($fp); exit(); The rb in the fopen function instructs PHP to open the file for reading in a binary safe manner. Hope this helps. Ash www.ashleysheridan.co.uk ---BeginMessage--- Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download problem
Hi, Thank you for your reply. I tried your code, but the problem remains. I still can download PDF, TXT, and MP3 fine, but the ODT, DOC, and JPG are still corrupted. I wonder why it works with some files and not with others... Stefano Ashley Sheridan ha scritto: Hi Stefano, You can use this code instead to read in the file and output it to the browser, as it is binary safe. I've used it for the same reason you require, and it works fine with video clips. $fp = fopen($path, rb); while(!feof($fp)) { print(fread($fp, 1024)); flush($fp); } fclose($fp); exit(); The rb in the fopen function instructs PHP to open the file for reading in a binary safe manner. Hope this helps. Ash www.ashleysheridan.co.uk Oggetto: [PHP] File download problem Da: Stefano Noffke [EMAIL PROTECTED] Data: Mon, 18 Aug 2008 16:01:22 +0200 A: php-general@lists.php.net A: php-general@lists.php.net Greetings, I need to create a script to let registered users to download files from a non-public folder. The files name, type, and size are stored in a MySQL Database. The user need to click on a link, and a PHP script should handle the download of the file. Here is how I organized it: The script gets the ID from the $_GET array, retrieve the name, type, and size from the database, and then it sends the following: [CODE] header(Content-Type: $type); header(Content-Length: . filesize($fileNameWithAbsolutePath)); header(Content-Transfer-Encoding: binary); header(Expires: 0); header(Cache-Control: no-cache, must-revalidate); header(Cache-Control: private); header(Content-Disposition: attachment; filename=\$fileName\); readfile($fileNameWithAbsolutePath) or die(File not found.); [/CODE] This script needs to work with any file type. I checked it and it works fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG which are corrupted and won't even open. Those are the only files I tried so far. I should add that the connection to the web page is encrypted through SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and MySQL version 5.0.51a. I cannot find any solution to this problem, and I hope that anyone here can help me. Thank you. Stefano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download Headers
Can any experts on this list explain to me why, despite the 1,000,000 places that application/octet-stream is documented to work, and has always worked, since Mosaic 1.0 days, people manage to find these goofball Content-type: headers that are supposed to work, but only work in a handful of browsers, and then they write tutorials as if it's the Right Way, and then those tutorials get past alleged Editors, and are all you can find from Google? Anybody? Cuz I really just don't understand why I'm seeing this same damn question about 5 times PER DAY between here and IRC ##php I just do not understand what is the aversion is to: Content-type: application/octet-stream IT WORKS! ALL BROWSERS! FOR ALL TIME! TRY IT!!! Mosaic 1.0, works. IE, all versions, works. Netscape/Mozilla/Firefox, all versions, works Safari, all versions, works. Lynx, all versions, works. It JUST WORKS! Why, oh why, are we endlessly seeing posts and tutorials using other headers that DO NOT WORK ON ALL BROWSERS. * Yes, ALL browsers, including Mosaic 1.0, thank you very much. This post was partially made in the probably futile hope that maybe somebody will find it and use it so I don't answer this question 5 times again tomorrow. Thank you. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Headers
Richard Lynch wrote: Can any experts on this list explain to me why, despite the 1,000,000 places that application/octet-stream is documented to work, and has always worked, since Mosaic 1.0 days, people manage to find these goofball Content-type: headers that are supposed to work, but only work in a handful of browsers, and then they write tutorials as if it's the Right Way, and then those tutorials get past alleged Editors, and are all you can find from Google? Anybody? Well, I can't vouch for any goofballs, their editors, nor google, but unfortunately sometimes an alternative to application/octet-stream has to be used to work around brokenness in certain versions of IE...We used octet-stream, and had a small portion of users complaining because they couldn't open the file that was downloaded - I can't open download.php, hence the workaround. - We can't use download.php?/filename.ext - (long story, but suffice it to say that it can't be done for non-technical reasons.) - IE doesn't take the Content-Disposition in some cases unless you use a different content-type. Our code basically does this: if (IE) { use wrong content type; if (IE 5.5) { use broken content disposition; } else { use normal content disposition; } } else { do things in a standard way; } jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Headers
On Thu, June 15, 2006 10:17 am, Jon Anderson wrote: Richard Lynch wrote: Can any experts on this list explain to me why, despite the 1,000,000 places that application/octet-stream is documented to work, and has always worked, since Mosaic 1.0 days, people manage to find these goofball Content-type: headers that are supposed to work, but only work in a handful of browsers, and then they write tutorials as if it's the Right Way, and then those tutorials get past alleged Editors, and are all you can find from Google? Anybody? Well, I can't vouch for any goofballs, their editors, nor google, but unfortunately sometimes an alternative to application/octet-stream has to be used to work around brokenness in certain versions of IE...We used octet-stream, and had a small portion of users complaining because they couldn't open the file that was downloaded - I can't open download.php, hence the workaround. But they downloaded it. They HAVE the data, it's just got a filename they don't know what to do with. If they just change the extension to whatever it should be, it would be fine. - We can't use download.php?/filename.ext - (long story, but suffice it to say that it can't be done for non-technical reasons.) Well, then, you've just eliminated a correct technical solution for non-technical reasons... I cannot do much about that... Actually, if you REALLY want to be browser-compliant back to the stone age, and througout the dreaded 3.x and 4.x series, you would need to get the URL to be just: http://example.com/script_that_looks_like_dirname/filename.ext That odd-looking dirname is a PHP script. URL juggling with mod_rewrite ForceType and $_SERVER['PATH_INFO'] is the tech. The browser then CANNOT screw up beause it looks like a static URL. - IE doesn't take the Content-Disposition in some cases unless you use a different content-type. Our code basically does this: if (IE) { use wrong content type; if (IE 5.5) { use broken content disposition; } else { use normal content disposition; } } else { do things in a standard way; } My code basically looks like this: header(Content-type: application/octet-stream); Though, admittedly, the 3 lines in .htaccess should count And, if you want input parameters in the URL instead of GET (which will mess up FDF files) then there's another 20 lines to parse $_SERVER['PATH_INFO'] into an array, just like $_GET and $_POST, only not. But then, that code is in an include file and gets re-used for a lot of different rich media (images, PDF, Ming flash movies, etc) so it's got a decent re-use factor. Maybe I'm just re-using code from 5 years ago that could be replaced by the browser-detecting (assuming the user-agent doesn't lie) and using some new-fangled headers... Or I could just keep using the code that cannot break. Yeah, I like that. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Problems
Chances are your 1KB file contains an error message - try changing the Content-Type to text/plain or text/html to see what PHP is throwing at you Cheers Chris Marek Kilimajer wrote: PHP Junkie wrote: Ave, I've been having a very nagging and frustrating problem for a while and I hope someone can help me out with this. I created a simple File Manager application, a lot of you already know about it as you helped me with coding at different stages. The problem is this: The Download. When you download a file, it's giving problems sometimes. What is happening is, a 1 KB file downloads instead of the actual file. And thus the file downloaded is no good. The file uploaded is absolutely perfect. Since I have the web server which contains this website, I'm easily able to check all these things. When a user uploads a file, it's uploaded absolutely perfect. It's not a 1 KB file.. The whole file is uploaded and it's not corrupt. But when a user downloads the file... Most of the time a 1 KB file is downloaded.. And its' corrupt of course. The more frustrating part is, it happens sometimes.. Not everytime. It is happening 90% of the time.. But sometimes it is able to download the actual file. If you try the same file from different locations, 15 times... 1 out of 15 times the file will download fine. I've been doing all sorts of testing to narrow down the problem but I don't know the problem. This is my download script : ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? Which is called using this link on the main page: a href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ img src=b_newtbl.png border=0/a What does the 1 KB file contain? Is it the beginning of the wanted file? Remove @ while debuging. Add header('Content-Lenght: ' . filesize($file)); Check server logs. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Problems
Ave, I made a change last evening, and since the change.. It seems to be working fine. Thus far I haven't had the 1 KB downloaded file problem. I have been trying all evening and this morning, from different places, and somehow right now it seems to be working fine. What I simply did was this: Instead of a href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ img src=b_newtbl.png border=0/a As my link to the download file, I changed it to a href=\imsafm_user_dl.php?F=imsafm/$user/$myrow[filename]\img src=b_newtbl.png border=0/a And changed the code in the download file to ?php header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($F)); @readfile($F); ? I didn¹t need to send the ID var to the download file, and I condensed the number of Variables I was passing. Somehow this seems to be working for me. I was just trying this out to one by one eliminate possibilities. And it works.Since I made this change, the actual file is being downloaded and not the 1 KB file. I don¹t really know why though. I understand I didn¹t need to divide the path into 2 variables. But what if I really needed to send the ID variable? I don¹t exactly understand how this setup of Variables affected the file being downloaded. Thanks anyways. On 9/15/04 5:35 PM, Marek Kilimajer [EMAIL PROTECTED] wrote: PHP Junkie wrote: Ave, I've been having a very nagging and frustrating problem for a while and I hope someone can help me out with this. I created a simple File Manager application, a lot of you already know about it as you helped me with coding at different stages. The problem is this: The Download. When you download a file, it's giving problems sometimes. What is happening is, a 1 KB file downloads instead of the actual file. And thus the file downloaded is no good. The file uploaded is absolutely perfect. Since I have the web server which contains this website, I'm easily able to check all these things. When a user uploads a file, it's uploaded absolutely perfect. It's not a 1 KB file.. The whole file is uploaded and it's not corrupt. But when a user downloads the file... Most of the time a 1 KB file is downloaded.. And its' corrupt of course. The more frustrating part is, it happens sometimes.. Not everytime. It is happening 90% of the time.. But sometimes it is able to download the actual file. If you try the same file from different locations, 15 times... 1 out of 15 times the file will download fine. I've been doing all sorts of testing to narrow down the problem but I don't know the problem. This is my download script : ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? Which is called using this link on the main page: a href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ img src=b_newtbl.png border=0/a What does the 1 KB file contain? Is it the beginning of the wanted file? Remove @ while debuging. Add header('Content-Lenght: ' . filesize($file)); Check server logs. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Problems
From: PHP Junkie [EMAIL PROTECTED] As my link to the download file, I changed it to a href=\imsafm_user_dl.php?F=imsafm/$user/$myrow[filename]\img src=b_newtbl.png border=0/a And changed the code in the download file to ?php header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($F)); @readfile($F); ? How are you validating $F and ensuring it's not a path to any file on your server? imsafm_user_dl.php?F=/home/path/to/secret/file.txt ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Problems
John Holmes wrote: From: PHP Junkie [EMAIL PROTECTED] As my link to the download file, I changed it to a href=\imsafm_user_dl.php?F=imsafm/$user/$myrow[filename]\img src=b_newtbl.png border=0/a And changed the code in the download file to ?php header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($F)); @readfile($F); ? How are you validating $F and ensuring it's not a path to any file on your server? imsafm_user_dl.php?F=/home/path/to/secret/file.txt It's a File Manager application, so I guess it's supposed to be accessible only to administrators that have (s)ftp access anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download Problems
Ave, I've been having a very nagging and frustrating problem for a while and I hope someone can help me out with this. I created a simple File Manager application, a lot of you already know about it as you helped me with coding at different stages. The problem is this: The Download. When you download a file, it's giving problems sometimes. What is happening is, a 1 KB file downloads instead of the actual file. And thus the file downloaded is no good. The file uploaded is absolutely perfect. Since I have the web server which contains this website, I'm easily able to check all these things. When a user uploads a file, it's uploaded absolutely perfect. It's not a 1 KB file.. The whole file is uploaded and it's not corrupt. But when a user downloads the file... Most of the time a 1 KB file is downloaded.. And its' corrupt of course. The more frustrating part is, it happens sometimes.. Not everytime. It is happening 90% of the time.. But sometimes it is able to download the actual file. If you try the same file from different locations, 15 times... 1 out of 15 times the file will download fine. I've been doing all sorts of testing to narrow down the problem but I don't know the problem. This is my download script : ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? Which is called using this link on the main page: a href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ img src=b_newtbl.png border=0/a I know that my Upload is working excellent so there's no point going into it. I check the file once it's uploaded on my Server and I find it's absolutely perfect... I try and download the same file using the same applications and it gets corrupted. I don't' know what to do. Can anyone help? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download Problems
PHP Junkie wrote: Ave, I've been having a very nagging and frustrating problem for a while and I hope someone can help me out with this. I created a simple File Manager application, a lot of you already know about it as you helped me with coding at different stages. The problem is this: The Download. When you download a file, it's giving problems sometimes. What is happening is, a 1 KB file downloads instead of the actual file. And thus the file downloaded is no good. The file uploaded is absolutely perfect. Since I have the web server which contains this website, I'm easily able to check all these things. When a user uploads a file, it's uploaded absolutely perfect. It's not a 1 KB file.. The whole file is uploaded and it's not corrupt. But when a user downloads the file... Most of the time a 1 KB file is downloaded.. And its' corrupt of course. The more frustrating part is, it happens sometimes.. Not everytime. It is happening 90% of the time.. But sometimes it is able to download the actual file. If you try the same file from different locations, 15 times... 1 out of 15 times the file will download fine. I've been doing all sorts of testing to narrow down the problem but I don't know the problem. This is my download script : ?php $file = $P/$F; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); @readfile($file); ? Which is called using this link on the main page: a href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ img src=b_newtbl.png border=0/a What does the 1 KB file contain? Is it the beginning of the wanted file? Remove @ while debuging. Add header('Content-Lenght: ' . filesize($file)); Check server logs. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download link not working in PHP 4.3.4
Curt, Thanks for the suggestions. Unfortunately, no luck yet. Here's the current version of the affected lines of code: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( 'Content-Disposition: attachment; filename=product.'.$file_ending.'' ); header ( 'Expires: ' . date ( 'r', 0 )); Still getting the same behavior, on both the Windows and Solaris platforms. Andy From: Curt Zirzow [EMAIL PROTECTED] Sent: Tuesday, March 30, 2004 9:56 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] File Download link not working in PHP 4.3.4 * Thus wrote Andrew Hauger ([EMAIL PROTECTED]): the file name. When the OK button is clicked, an error dialog pops up with the message Internet Explorer cannot download ... [snipped URL]. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. This can mean a lot of things, IE tends to be too friendly sometimes. Here are the header commands: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( Content-Disposition: attachment; filename=product..$file_ending ); Quote the filename, although it most likley wont be the problem. Conent-Type: attachment; filename=product.xls header ( Expires: 0 ); I might wage this is the problem, it needs to be a valid HTTP date, something like this will do the job: header('Expires: ' . date('r', 0); Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.624 / Virus Database: 401 - Release Date: 3/15/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download link not working in PHP 4.3.4
Check the comments on this page: http://us2.php.net/manual/en/function.session-cache-limiter.php ---John Holmes... - Original Message - From: Andrew Hauger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 31, 2004 11:18 AM Subject: Re: [PHP] File Download link not working in PHP 4.3.4 Curt, Thanks for the suggestions. Unfortunately, no luck yet. Here's the current version of the affected lines of code: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( 'Content-Disposition: attachment; filename=product.'.$file_ending.'' ); header ( 'Expires: ' . date ( 'r', 0 )); Still getting the same behavior, on both the Windows and Solaris platforms. Andy From: Curt Zirzow [EMAIL PROTECTED] Sent: Tuesday, March 30, 2004 9:56 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] File Download link not working in PHP 4.3.4 * Thus wrote Andrew Hauger ([EMAIL PROTECTED]): the file name. When the OK button is clicked, an error dialog pops up with the message Internet Explorer cannot download ... [snipped URL]. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. This can mean a lot of things, IE tends to be too friendly sometimes. Here are the header commands: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( Content-Disposition: attachment; filename=product..$file_ending ); Quote the filename, although it most likley wont be the problem. Conent-Type: attachment; filename=product.xls header ( Expires: 0 ); I might wage this is the problem, it needs to be a valid HTTP date, something like this will do the job: header('Expires: ' . date('r', 0); Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.624 / Virus Database: 401 - Release Date: 3/15/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download link not working in PHP 4.3.4
I have a script that dynamically generates a CSV file for downloading to MS Excel. The script works fine in PHP 4.3.3 on a Windows machine using Apache 2, and the exact same script does not work in PHP 4.3.4 on Solaris 9 using Apache 1.3.29. A script with essentially the same header commands works in PHP 4.3.1 on Solaris 9 using Apache 1.3.27. The script is supposed to pop up a window to prompt the user to either open the document from its current location or save it to disk. On the systems that work, the window pops up with the expected file name. On the system that does not work, the window pops up with the URL for the script that generates the file instead of the file name. When the OK button is clicked, an error dialog pops up with the message Internet Explorer cannot download ... [snipped URL]. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. Here are the header commands: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( Content-Disposition: attachment; filename=product..$file_ending ); header ( Expires: 0 ); header ( Connection: Keep-Alive ); Thanks in advance for any helpful suggestions. Andy Hauger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download link not working in PHP 4.3.4
* Thus wrote Andrew Hauger ([EMAIL PROTECTED]): the file name. When the OK button is clicked, an error dialog pops up with the message Internet Explorer cannot download ... [snipped URL]. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. This can mean a lot of things, IE tends to be too friendly sometimes. Here are the header commands: $file_type = vnd.ms-excel; $file_ending = xls; header ( Content-Type: application/$file_type ); header ( Content-Disposition: attachment; filename=product..$file_ending ); Quote the filename, although it most likley wont be the problem. Conent-Type: attachment; filename=product.xls header ( Expires: 0 ); I might wage this is the problem, it needs to be a valid HTTP date, something like this will do the job: header('Expires: ' . date('r', 0); Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file download using header
I am having some trouble making it possible to download a file using the header function. The problems are: (1) I get the dialog box to download the file, but for some reason the type of file isn't getting passed to the box, and (2) when I download a 4MB file it only seems to be getting 16.6KB. I haven't used header for this purpose before this, so maybe I am missing something. I Googled around and found the content-disposition type I thought I needed, I actually tried 3 different types (the file is a compressed zip file). I Googled around for tutorials on downloading files and still haven't found the answer to correcting my problem. Here is the code I am using, maybe a couple more trained eyes looking at this could help me out. ?php $download = 'http://www.usa-financial.com'.urldecode( $_GET['link'] ); $type = urldecode( $_GET['type'] ); $size = filesize( '/home2/www/usa-financial'.urldecode( $_GET['link'] ) ); header(Content-type: $type); header(Content-Disposition: attachment; filename=$download;); header(Accept-Ranges: bytes); header(Content-Length: $size); echo !-- $type \n $size \n $download \n --\n; ? Josh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download
Hi there, I would like to send an arbitrary file to a user. This file will be on the server in the PHP directory. I will also want to rename it before it is sent, but keep the old file with the old filename. Any help is appreciated... Thanks, Grant -- Grant Rutherford Iders Incorporated 600A Clifton Street Winnipeg, MB R3G 2X6 http://www.iders.ca tel: 204-779-5400 ext 36 fax: 204-779-5444 Iders Incorporated: Confidential Note: This message is intended solely for the use of the designated recipient(s) and their appointed delegates, and may contain confidential information. Any unauthorized disclosure, copying or distribution of its contents is strictly prohibited. If you have received this message in error, please destroy it and advise the sender immediately by phone, Email or facsimile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download
Maybe I should clarify this: I have a the php file: /var/www/html/dev/view_files_disply.php This file accepts a POST argument which identifies $filename (example 1392_foobar.txt) of a file stored on the server at: /var/www/html/files/1392_foobar.txt This filename is generated by PHP and is therefore rather cryptic. I have more meaningful filenames stored in a database example: 1392_foobar.txt - foobar.txt I would like the view_files_display.php script to send the appropriate file to the user, with the appropriate filename (foobar.txt), but to leave the file 1392_foobar.txt on the server unmodified for future requests. I am currently considering copying the file and renaming it, and then using a header(location=) to redirect the user to the renamed file, but I'm not sure how to ensure that the temporary file is deleted afterwards. Any suggestions? Thanks, Grant Grant Rutherford wrote: Hi there, I would like to send an arbitrary file to a user. This file will be on the server in the PHP directory. I will also want to rename it before it is sent, but keep the old file with the old filename. Any help is appreciated... Thanks, Grant -- Grant Rutherford Iders Incorporated 600A Clifton Street Winnipeg, MB R3G 2X6 http://www.iders.ca tel: 204-779-5400 ext 36 fax: 204-779-5444 Iders Incorporated: Confidential Note: This message is intended solely for the use of the designated recipient(s) and their appointed delegates, and may contain confidential information. Any unauthorized disclosure, copying or distribution of its contents is strictly prohibited. If you have received this message in error, please destroy it and advise the sender immediately by phone, Email or facsimile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download problem using Netscape 7.x
Hello, I have some files on a website which the user can download (e.g. pdf, zip...). The files sould not bw displayes but the browser should aks the user what to do (e.g. save it to disk, open it). My code look like this: header(Content-type: application/octet-stream); header(Content-disposition: attachment; filename=$userfile); header(Content-Length: .filesize($userfile)); header(Content-Transfer-Encoding: binary\n); if($fp = fopen($userfile, rb) fpassthru($fp); This works fine in most browsers except Netscape 7.x. Here the file is saved as document.pdf.php instead of document.pdf. Does anyone know how to fix this? Any help is appreciated. Yours, Uli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download by php header...
Found the problem. It is the odbc_connect() that cause the download to fall short of completing it's download. Weird! I think it's because the database connection have a slower response time than the download response time. PHP header should not be affected by the odbc function... But then I remember about the past problem with the CGI Error when it come to php header function and odbc which I don't have this problem with ISAPI. Funny I'm getting this problem, but fortunately, the workaround is to do the odbc connection after I use the php header and that took care of it. Curt Zirzow [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] * Thus wrote Scott Fletcher ([EMAIL PROTECTED]): Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? It doesn't. Your script is taking over 30 seconds to run you will need to find out why and where its taking to long or extend your time-out setting. btw, also on the content-disposition, not only will some browsers not honor that, they will just use the name of the script as the 'save-as' filename. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download by php header...
Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? Thanks, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download by php header...
At 16:15 21-7-03, you wrote: Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? It seems like $DownloadUpdateArray[$_REQUEST['dw_code']][1] takes so long. Or the previous code alwyas takes 29.9 secs, who knows. You can tell php.ini that scripts can take some time longer dan 30 secs, or you can add a line to prolong the script time (http://nl2.php.net/function.set-time-limit) or you can try to make that function faster. I have some extra headers to prevent several problems: header(Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT); // always modified header(Cache-Control: no-store, no-cache, must-revalidate); // HTTP/1.1 header(Cache-Control: post-check=0, pre-check=0, false); header(Pragma: no-cache); // HTTP/1.0 header(Content-type: text/csv); //adapt to your file type header('Content-Disposition: inline; filename=filename.ext'); Note that internet explorer 5.5 does not accept the 'attachment' part so for your header with 'attachement;' in it consider to add this conditional: if (strstr($_SERVER[HTTP_USER_AGENT],MSIE 5.5)) {$att = ;} else {$att = attachment;;} Thanks, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download by php header...
* Thus wrote Scott Fletcher ([EMAIL PROTECTED]): Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? It doesn't. Your script is taking over 30 seconds to run you will need to find out why and where its taking to long or extend your time-out setting. btw, also on the content-disposition, not only will some browsers not honor that, they will just use the name of the script as the 'save-as' filename. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download by php header...
Um, problem is I don't have any scripts before this sample header function. So, something is up. Does the file size 49 MB have something to do with it? Okay, saw both of the replies, so will check them out. Thanks, Scott Curt Zirzow [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] * Thus wrote Scott Fletcher ([EMAIL PROTECTED]): Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? It doesn't. Your script is taking over 30 seconds to run you will need to find out why and where its taking to long or extend your time-out setting. btw, also on the content-disposition, not only will some browsers not honor that, they will just use the name of the script as the 'save-as' filename. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download by php header...
btw, also on the content-disposition, not only will some browsers not honor that, they will just use the name of the script as the 'save-as' filename. That's okay with the 'save as' filename because no one know hte real filename on the webserver because it is renamed when it is download anyway. Curt Zirzow [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] * Thus wrote Scott Fletcher ([EMAIL PROTECTED]): Hi! I'm using PHP 4.3.2 and IIS 5.0. I'm using the PHP header to cause the webserver to download the file to the web browser. Some of the time it work and some of the other time, it doesnt. I haven't figured out why until I looked in the error log which showed hte problem... See two clipping below. --snip-- //Send Downloadable File(s) To Browsers... $total=$DownloadUpdateArray[$_REQUEST['dw_code']][0]; header (Content-Type: application/octet-stream); header (Content-Length: .filesize($total)); header (Content-Disposition: attachment; filename=.$DownloadUpdateArray[$_REQUEST['dw_code']][1]); readfile($total); --snip-- --snip-- [21-Jul-2003 09:15:33] PHP Fatal error: Maximum execution time of 30 seconds exceeded in D:\filepath\menu\tech_support.php on line 47 --snip So, how does the php header(content-disposition:attachment; filename='***') cause the php timeout in the first place, what seem to be the problem? It doesn't. Your script is taking over 30 seconds to run you will need to find out why and where its taking to long or extend your time-out setting. btw, also on the content-disposition, not only will some browsers not honor that, they will just use the name of the script as the 'save-as' filename. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download?
On Friday 04 April 2003 15:29, b b wrote: It would be: a href=downloadFile.php?daFile=path/fileNamepath/fileName/a I tried to print the _GET['daFile'] however if I am using the header function in the same file then it won't print a thing. Well, disable the file downloading section for the moment. In fact it starts downloading. The only thing is that it doesn't catch the correct file name (though it downloads the actual daFile). I don't quite understand this bit -- could you clarify? One thing that you should do when passing values through the URL is to urlencode() them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download
Hi, Anybody knows the solution to the following: I am trying to force the download of a file called dadada.txt. I have a file named downloadFile.php It is invoked like this: a href=downloadFile.php?daFile=path/dadada.txtdadada.txt/a However within the downloadFile.php the $daFile argument is empty. This is the file: ? session_start(); if($_SESSION['isValidSession'] == 'Y'){ $daFile = $_GET['daFile']; $size=filesize($daFile); if($daFile != ){ //header(Cache-control: private); header(Content-Type: texapplication/octet-stream\n); header(Content-Length: . $size .\n); header(Content-Disposition: attachment; filename=\$daFile\\n); // header(Content-Transfer-Encoding: binary); } require(footer.php); }else{ printf(br You are not autherized to view this page); } ? A download happens but the downloaded file name is downloadFile and not dadada.txt Why would you think this is happening? Cheers. __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download?
Hi, Why would the $daFile in the following code be resolved to . I am passing it via the url. ? session_start(); if($_SESSION['isValidSession'] == 'Y'){ $daFile = $_GET['daFile']; $size=filesize($daFile); if($daFile != ){ //header(Cache-control: private); header(Content-Type: texapplication/octet-stream\n); header(Content-Length: . $size .\n); header(Content-Disposition: attachment; filename=\$daFile\\n); } require(footer.php); }else{ printf(br You are not autherized to view this page); } ? __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download?
On Friday 04 April 2003 13:51, b b wrote: Why would the $daFile in the following code be resolved to . I am passing it via the url. ? session_start(); if($_SESSION['isValidSession'] == 'Y'){ $daFile = $_GET['daFile']; - What URL are you using? - Have you taken case into account? - What does print_r($_GET) give you? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Before borrowing money from a friend, decide which you need more. -- Addison H. Hallock */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download?
It would be: a href=downloadFile.php?daFile=path/fileNamepath/fileName/a I tried to print the _GET['daFile'] however if I am using the header function in the same file then it won't print a thing. In fact it starts downloading. The only thing is that it doesn't catch the correct file name (though it downloads the actual daFile). Cheers, r. --- Jason Wong [EMAIL PROTECTED] wrote: On Friday 04 April 2003 13:51, b b wrote: Why would the $daFile in the following code be resolved to . I am passing it via the url. ? session_start(); if($_SESSION['isValidSession'] == 'Y'){ $daFile = $_GET['daFile']; - What URL are you using? - Have you taken case into account? - What does print_r($_GET) give you? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Before borrowing money from a friend, decide which you need more. -- Addison H. Hallock */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download
Hello I have a script that after login gives the user access to one directory. The directory depends on their login. After login a list of files is displayed with a check box in front of each file. Under the list of files there are several buttons, Copy, Delete, Rename, Upload, and Download. When you check a box, and select a a button, lets say copy, you are given a new window to enter the new name. Once entered and you select continue the a copy is made and the list of files is refreshed, displaying also the new file. All the buttons function this way except the download which is where I have problems. I a file management class I have a function for each operation. The code for the download function is as follows: function downloadFile($filename) { $result = ; if(file_exists($this-_memberDir . / . $filename)) { header(Content-type: application/octet-stream); header(Content-Disposition: attachment; filename=$filename); header(Pragma: no-cache); if (!readfile($this-_memberDir . / . $filename)) $result = $filename . successfully downloadedbr; } else { $result = Download Failed for . $filename . , does not existbr; } return $result; } When this function runs, I get the download box that allows the user to select where they want to save there file and a file gets saved. After this code returns the $result should be printed at the top of the browser window and the list of files displayed again. What happens is the results and the list of files, the html code for the next screen, is appended to the end of the file that was downloaded. I can put an exit() inplace of return and I get the correct file size downloaded but I still don't get my screen refreshed. I would think that I should be able to put another header statement after the download to indicate the no more data goes into the file but is to be displayed by the browser. I can't figure out how to get this to work. Thanks David Miller -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Download
have the file download in a popup window. after the down load the window will be gone. Then you don't have to worry about the refreshing of the main window. Jim - Original Message - From: David Miller [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, March 06, 2003 8:30 AM Subject: [PHP] File Download Hello I have a script that after login gives the user access to one directory. The directory depends on their login. After login a list of files is displayed with a check box in front of each file. Under the list of files there are several buttons, Copy, Delete, Rename, Upload, and Download. When you check a box, and select a a button, lets say copy, you are given a new window to enter the new name. Once entered and you select continue the a copy is made and the list of files is refreshed, displaying also the new file. All the buttons function this way except the download which is where I have problems. I a file management class I have a function for each operation. The code for the download function is as follows: function downloadFile($filename) { $result = ; if(file_exists($this-_memberDir . / . $filename)) { header(Content-type: application/octet-stream); header(Content-Disposition: attachment; filename=$filename); header(Pragma: no-cache); if (!readfile($this-_memberDir . / . $filename)) $result = $filename . successfully downloadedbr; } else { $result = Download Failed for . $filename . , does not existbr; } return $result; } When this function runs, I get the download box that allows the user to select where they want to save there file and a file gets saved. After this code returns the $result should be printed at the top of the browser window and the list of files displayed again. What happens is the results and the list of files, the html code for the next screen, is appended to the end of the file that was downloaded. I can put an exit() inplace of return and I get the correct file size downloaded but I still don't get my screen refreshed. I would think that I should be able to put another header statement after the download to indicate the no more data goes into the file but is to be displayed by the browser. I can't figure out how to get this to work. Thanks David Miller -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download + HTTP auth problem.
Hello, I have this simple script called index.php in a directory protected with HTTP auth (require valid-user): ?php $archivo = '/somewhere/out/docroot/registro.csv'; header('Content-Type: application/octect-stream'); header('Content-Length: '.filesize($archivo)); header('Content-Disposition: attachment; filename=registro.csv'); readfile($archivo); ? When I access the directory with Netscape/Mozilla/Galeon it works fine, Apache asks the login and password and the script sends the file. But with MSIE 6.x (from Windows XP) it does not work: it presents the download dialog asking to save or open the file, but then MSIE reports an error and does not download the file. I discovered later that Konqueror asks for the login and password again when the download starts. What could be causing this?. Thanks in advance. Rodolfo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download + HTTP auth problem.
Simply, HTTP Authentification Header(WWW-Authenticate: Basic realm='something') does not work with microsoft product, so you need to buy Microsoft authentification from Microsoft to do something like it. - Original Message - From: Rodolfo Gonzalez [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 6:29 AM Subject: [PHP] File download + HTTP auth problem. Hello, I have this simple script called index.php in a directory protected with HTTP auth (require valid-user): ?php $archivo = '/somewhere/out/docroot/registro.csv'; header('Content-Type: application/octect-stream'); header('Content-Length: '.filesize($archivo)); header('Content-Disposition: attachment; filename=registro.csv'); @readfile($archivo); ? When I access the directory with Netscape/Mozilla/Galeon it works fine, Apache asks the login and password and the script sends the file. But with MSIE 6.x (from Windows XP) it does not work: it presents the download dialog asking to save or open the file, but then MSIE reports an error and does not download the file. I discovered later that Konqueror asks for the login and password again when the download starts. What could be causing this?. Thanks in advance. Rodolfo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] File download doesn't work with SSL
Okay, I tried just a page with only session_start() in it and the page does send a no-cache, no-store header. output from wget D:\wgetwget -S http://coconut/usap/test.php --08:04:13-- http://coconut/usap/test.php = `test.php.2' Resolving coconut... done. Connecting to coconut[192.168.2.124]:80... connected. HTTP request sent, awaiting response... 1 HTTP/1.1 200 OK 2 Server: Microsoft-IIS/5.1 3 Date: Tue, 08 Oct 2002 12:04:13 GMT 4 Content-type: text/html 5 X-Powered-By: PHP/4.2.3 6 Set-Cookie: PHPSESSID=9c3229d0448971b469b1af2af66a19b8; path=/ 7 Expires: Thu, 19 Nov 1981 08:52:00 GMT 8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 9 Pragma: no-cache [ = ] 0 --.--K/s 08:04:13 (0.00 B/s) - `test.php.2' saved [0] end output from wget This is on my test server at home, under normal HTTP, but I imagine it would be the same under HTTPS at work. Is there any way to change this without messing with the source code? ---John Holmes... -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 1:00 AM To: Tom Rogers Cc: John W. Holmes; [EMAIL PROTECTED] Subject: Re[2]: [PHP] File download doesn't work with SSL Why not just a simple wget -S https://... to see the headers? On Tue, 8 Oct 2002, Tom Rogers wrote: Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] File download doesn't work with SSL
Also, FYI, pages without session_start do not send that cache-control header. ---John Holmes... -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 8:08 AM To: 'Rasmus Lerdorf'; 'Tom Rogers' Cc: [EMAIL PROTECTED] Subject: RE: Re[2]: [PHP] File download doesn't work with SSL Okay, I tried just a page with only session_start() in it and the page does send a no-cache, no-store header. output from wget D:\wgetwget -S http://coconut/usap/test.php --08:04:13-- http://coconut/usap/test.php = `test.php.2' Resolving coconut... done. Connecting to coconut[192.168.2.124]:80... connected. HTTP request sent, awaiting response... 1 HTTP/1.1 200 OK 2 Server: Microsoft-IIS/5.1 3 Date: Tue, 08 Oct 2002 12:04:13 GMT 4 Content-type: text/html 5 X-Powered-By: PHP/4.2.3 6 Set-Cookie: PHPSESSID=9c3229d0448971b469b1af2af66a19b8; path=/ 7 Expires: Thu, 19 Nov 1981 08:52:00 GMT 8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 9 Pragma: no-cache [ = ] 0 --.--K/s 08:04:13 (0.00 B/s) - `test.php.2' saved [0] end output from wget This is on my test server at home, under normal HTTP, but I imagine it would be the same under HTTPS at work. Is there any way to change this without messing with the source code? ---John Holmes... -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 1:00 AM To: Tom Rogers Cc: John W. Holmes; [EMAIL PROTECTED] Subject: Re[2]: [PHP] File download doesn't work with SSL Why not just a simple wget -S https://... to see the headers? On Tue, 8 Oct 2002, Tom Rogers wrote: Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] File download doesn't work with SSL
Right, I figured you knew this as it is documented. You can change that in your php.ini file using the session.cache_limiter directive. -Rasmus On Tue, 8 Oct 2002, John W. Holmes wrote: Also, FYI, pages without session_start do not send that cache-control header. ---John Holmes... -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 8:08 AM To: 'Rasmus Lerdorf'; 'Tom Rogers' Cc: [EMAIL PROTECTED] Subject: RE: Re[2]: [PHP] File download doesn't work with SSL Okay, I tried just a page with only session_start() in it and the page does send a no-cache, no-store header. output from wget D:\wgetwget -S http://coconut/usap/test.php --08:04:13-- http://coconut/usap/test.php = `test.php.2' Resolving coconut... done. Connecting to coconut[192.168.2.124]:80... connected. HTTP request sent, awaiting response... 1 HTTP/1.1 200 OK 2 Server: Microsoft-IIS/5.1 3 Date: Tue, 08 Oct 2002 12:04:13 GMT 4 Content-type: text/html 5 X-Powered-By: PHP/4.2.3 6 Set-Cookie: PHPSESSID=9c3229d0448971b469b1af2af66a19b8; path=/ 7 Expires: Thu, 19 Nov 1981 08:52:00 GMT 8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 9 Pragma: no-cache [ = ] 0 --.--K/s 08:04:13 (0.00 B/s) - `test.php.2' saved [0] end output from wget This is on my test server at home, under normal HTTP, but I imagine it would be the same under HTTPS at work. Is there any way to change this without messing with the source code? ---John Holmes... -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 1:00 AM To: Tom Rogers Cc: John W. Holmes; [EMAIL PROTECTED] Subject: Re[2]: [PHP] File download doesn't work with SSL Why not just a simple wget -S https://... to see the headers? On Tue, 8 Oct 2002, Tom Rogers wrote: Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] File download doesn't work with SSL
No, I hadn't realized that's what controlled the no-cache being sent. I switched it to none and it works now. Thanks. ---John Holmes... -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 9:55 AM To: John W. Holmes Cc: 'Tom Rogers'; [EMAIL PROTECTED] Subject: RE: Re[2]: [PHP] File download doesn't work with SSL Right, I figured you knew this as it is documented. You can change that in your php.ini file using the session.cache_limiter directive. -Rasmus On Tue, 8 Oct 2002, John W. Holmes wrote: Also, FYI, pages without session_start do not send that cache-control header. ---John Holmes... -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 8:08 AM To: 'Rasmus Lerdorf'; 'Tom Rogers' Cc: [EMAIL PROTECTED] Subject: RE: Re[2]: [PHP] File download doesn't work with SSL Okay, I tried just a page with only session_start() in it and the page does send a no-cache, no-store header. output from wget D:\wgetwget -S http://coconut/usap/test.php --08:04:13-- http://coconut/usap/test.php = `test.php.2' Resolving coconut... done. Connecting to coconut[192.168.2.124]:80... connected. HTTP request sent, awaiting response... 1 HTTP/1.1 200 OK 2 Server: Microsoft-IIS/5.1 3 Date: Tue, 08 Oct 2002 12:04:13 GMT 4 Content-type: text/html 5 X-Powered-By: PHP/4.2.3 6 Set-Cookie: PHPSESSID=9c3229d0448971b469b1af2af66a19b8; path=/ 7 Expires: Thu, 19 Nov 1981 08:52:00 GMT 8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 9 Pragma: no-cache [ = ] 0 --.--K/s 08:04:13 (0.00 B/s) - `test.php.2' saved [0] end output from wget This is on my test server at home, under normal HTTP, but I imagine it would be the same under HTTPS at work. Is there any way to change this without messing with the source code? ---John Holmes... -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 1:00 AM To: Tom Rogers Cc: John W. Holmes; [EMAIL PROTECTED] Subject: Re[2]: [PHP] File download doesn't work with SSL Why not just a simple wget -S https://... to see the headers? On Tue, 8 Oct 2002, Tom Rogers wrote: Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File download doesn't work with SSL
Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes...
Re: [PHP] File download doesn't work with SSL
Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
Does it work with a different browser? Smells like an IE bug to me. Doesn't everything with IE smell like a bug? Anyhow, it works fine with Netscape. Opera will not open the file, but will save-as just fine when prompted. I'm off to search MS...deity of choice help me... ---John Holmes... Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:08 AM Subject: Re: [PHP] File download doesn't work with SSL Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:08 AM Subject: Re: [PHP] File download doesn't work with SSL Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
John, problem is broken HTTP/1.1 implementation of Internet Exploder. Make your server downgrade to HHTP/1.0. e.g. for apache: example IfModule mod_setenvif.c # # The following directives modify normal HTTP response behavior. # The first directive disables keepalive for Netscape 2.x and browsers that # spoof it. There are known problems with these browser implementations. # The second directive is for Microsoft Internet Explorer 4.0b2 # which has a broken HTTP/1.1 implementation and does not properly # support keepalive when it is used on 301 or 302 (redirect) responses. # BrowserMatch Mozilla/2 nokeepalive BrowserMatch MSIE nokeepalive downgrade-1.0 force-response-1.0 # # The following directive disables HTTP/1.1 responses to browsers which # are in violation of the HTTP/1.0 spec by not being able to grok a # basic 1.1 response. # BrowserMatch RealPlayer 4\.0 force-response-1.0 BrowserMatch Java/1\.0 force-response-1.0 BrowserMatch JDK/1\.0 force-response-1.0 /IfModule /example copy BrowserMatch line in SSL virtual server section too. -Stathis. Rasmus Lerdorf wrote: Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:08 AM Subject: Re: [PHP] File download doesn't work with SSL Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Rouvas Stathis [EMAIL PROTECTED] http://www.di.uoa.gr/~rouvas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
Stathis, Thanks for the tip. Any idea how to fix IIS regarding this issue? ---John Holmes... - Original Message - From: Rouvas Stathis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: 1LT John W. Holmes [EMAIL PROTECTED] Sent: Monday, October 07, 2002 2:00 PM Subject: Re: [PHP] File download doesn't work with SSL John, problem is broken HTTP/1.1 implementation of Internet Exploder. Make your server downgrade to HHTP/1.0. e.g. for apache: example IfModule mod_setenvif.c # # The following directives modify normal HTTP response behavior. # The first directive disables keepalive for Netscape 2.x and browsers that # spoof it. There are known problems with these browser implementations. # The second directive is for Microsoft Internet Explorer 4.0b2 # which has a broken HTTP/1.1 implementation and does not properly # support keepalive when it is used on 301 or 302 (redirect) responses. # BrowserMatch Mozilla/2 nokeepalive BrowserMatch MSIE nokeepalive downgrade-1.0 force-response-1.0 # # The following directive disables HTTP/1.1 responses to browsers which # are in violation of the HTTP/1.0 spec by not being able to grok a # basic 1.1 response. # BrowserMatch RealPlayer 4\.0 force-response-1.0 BrowserMatch Java/1\.0 force-response-1.0 BrowserMatch JDK/1\.0 force-response-1.0 /IfModule /example copy BrowserMatch line in SSL virtual server section too. -Stathis. Rasmus Lerdorf wrote: Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:08 AM Subject: Re: [PHP] File download doesn't work with SSL Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Rouvas Stathis [EMAIL PROTECTED] http://www.di.uoa.gr/~rouvas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
John, sorry, don't know zip about IIS. I got the info from URL:http://www.squirrelmail.org/wiki/InternetExplorerVersusSSL though. Maybe they have more to say... -Stathis. 1LT John W. Holmes wrote: Stathis, Thanks for the tip. Any idea how to fix IIS regarding this issue? ---John Holmes... - Original Message - From: Rouvas Stathis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: 1LT John W. Holmes [EMAIL PROTECTED] Sent: Monday, October 07, 2002 2:00 PM Subject: Re: [PHP] File download doesn't work with SSL John, problem is broken HTTP/1.1 implementation of Internet Exploder. Make your server downgrade to HHTP/1.0. e.g. for apache: example IfModule mod_setenvif.c # # The following directives modify normal HTTP response behavior. # The first directive disables keepalive for Netscape 2.x and browsers that # spoof it. There are known problems with these browser implementations. # The second directive is for Microsoft Internet Explorer 4.0b2 # which has a broken HTTP/1.1 implementation and does not properly # support keepalive when it is used on 301 or 302 (redirect) responses. # BrowserMatch Mozilla/2 nokeepalive BrowserMatch MSIE nokeepalive downgrade-1.0 force-response-1.0 # # The following directive disables HTTP/1.1 responses to browsers which # are in violation of the HTTP/1.0 spec by not being able to grok a # basic 1.1 response. # BrowserMatch RealPlayer 4\.0 force-response-1.0 BrowserMatch Java/1\.0 force-response-1.0 BrowserMatch JDK/1\.0 force-response-1.0 /IfModule /example copy BrowserMatch line in SSL virtual server section too. -Stathis. Rasmus Lerdorf wrote: Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:08 AM Subject: Re: [PHP] File download doesn't work with SSL Does it work with a different browser? Smells like an IE bug to me. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: Everyone, I've had a simple download script working where a user would click on a link and the program would send word or excel headers instead of HTML. The file would then be opened in the appropriate program and the user could save/edit it. Now that we've loaded everything under SSL, it doesn't work. Here are the headers I send: header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); Now, the pages in question are just regular HTML tables. If there is a export2=excel in the URL, then these two additional headers will be sent. The dialog to save/open the file pops up, but when you try to open/save the file, IE says it cannot be found. If I put in a echo before these two headers (or comment them out), the page is shown correctly as HTML, so the code is correct. Are there any special headers I have to send to enable this file download while under SSL, or is it something else I'm overlooking? Thanks for any help. ---John Holmes... -- Rouvas Stathis [EMAIL PROTECTED] http://www.di.uoa.gr/~rouvas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
Are you sure? I think (I might be wrong) using PHP sessions automatically sends the Cache-Control header. I cannot remember what directives it uses. Perhaps the fact that you do not use correct case makes PHP miss the fact that you want to reassign Cache-Control to use a different value? If this is true, you might be sending: Cache-Control: no-cache cache-control: no-store Just an idea ... Chris Rasmus Lerdorf wrote: Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File download doesn't work with SSL
I had tried it with both cases, actually, just to be sure. It did not make a difference. If the session is sending a no-cache header, would then sending a no-store one cancel the other out, or just add to it? ---John Holmes... -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED]] Sent: Monday, October 07, 2002 8:45 PM To: Rasmus Lerdorf Cc: 1LT John W. Holmes; [EMAIL PROTECTED] Subject: Re: [PHP] File download doesn't work with SSL Are you sure? I think (I might be wrong) using PHP sessions automatically sends the Cache-Control header. I cannot remember what directives it uses. Perhaps the fact that you do not use correct case makes PHP miss the fact that you want to reassign Cache-Control to use a different value? If this is true, you might be sending: Cache-Control: no-cache cache-control: no-store Just an idea ... Chris Rasmus Lerdorf wrote: Nope, PHP does not send that. On Mon, 7 Oct 2002, 1LT John W. Holmes wrote: I believe in miracles. I have searched Microsoft and the first link was actually related to my problem... Okay, I found an IE issue where downloads over SSL will choke when you send a no-cache header. It says to use a no-store cache-control header, instead. I tried this: header(cache-control: no-store); header(content-type: application/vnd.ms-excel; name='excel'); header(content-disposition: attachment; filename= . $filename . .xls); and I'm still getting the same thing. Is the no-cache cache-control header sent automatically by PHP at all? I don't have one set explicitly in my code. Any help is appreciated. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
You can have multiple directives in that header: Cache-Control: no-cache, no-store Do you have a way to view the HTTP? Chris John W. Holmes wrote: I had tried it with both cases, actually, just to be sure. It did not make a difference. If the session is sending a no-cache header, would then sending a no-store one cancel the other out, or just add to it? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File download doesn't work with SSL
You can have multiple directives in that header: Cache-Control: no-cache, no-store Do you have a way to view the HTTP? No. Can you recommend a good method on windows? Should I get lynx or does opera have a method to view all the headers? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File download doesn't work with SSL
You can have multiple directives in that header: Cache-Control: no-cache, no-store Do you have a way to view the HTTP? No. Can you recommend a good method on windows? Should I get lynx or does opera have a method to view all the headers? can't you view all headers etc in the source of the pages? pretty sure can view all headers sent to the browser in both ie and NN... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] File download doesn't work with SSL
Hi, Tuesday, October 8, 2002, 12:13:59 PM, you wrote: You can have multiple directives in that header: Cache-Control: no-cache, no-store Do you have a way to view the HTTP? JWH No. Can you recommend a good method on windows? Should I get lynx or JWH does opera have a method to view all the headers? JWH ---John Holmes... You may find this very usefull: http://www.ethereal.com/ -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] File download doesn't work with SSL
Tuesday, October 8, 2002, 12:13:59 PM, you wrote: You can have multiple directives in that header: Cache-Control: no-cache, no-store Do you have a way to view the HTTP? JWH No. Can you recommend a good method on windows? Should I get lynx or JWH does opera have a method to view all the headers? JWH ---John Holmes... You may find this very usefull: http://www.ethereal.com/ Wouldn't everything be encrypted, though, since it's over SSL? Including the headers? Unfortunately, the way they set up the server, it will not process any unsecured requests now. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] File download doesn't work with SSL
Hi, Tuesday, October 8, 2002, 12:59:40 PM, you wrote: JWH Wouldn't everything be encrypted, though, since it's over SSL? Including JWH the headers? JWH Unfortunately, the way they set up the server, it will not process any JWH unsecured requests now. JWH ---John Holmes... Yes it is encrypted ... quite a mess :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File download doesn't work with SSL
Yes, you're right. You might want to turn off the forced SSL temporarily to debug this, if that's possible. Nothing other than your browser or the Web server will be able to show you the HTTP communication over SSL, because it's all trash to everything in between. There may be settings in Opera that can help you debug things; I'm not sure. I am not aware of any browser that does that for you, though it would be very handy. I wrote an HTTP proxy in PHP for my own use in such affairs. Email me if you would like to try it to see if it helps. Chris John W. Holmes wrote: You may find this very usefull: http://www.ethereal.com/ Wouldn't everything be encrypted, though, since it's over SSL? Including the headers? Unfortunately, the way they set up the server, it will not process any unsecured requests now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File download doesn't work with SSL
Thanks for the help guys. Like I said, the download works fine as long as it's not over SSL. I will try to disable it and see if I can look at the headers sent to see if a no-cache header is being sent, even though I haven't specified it. Regardless, even if it is, I have no way of stopping it, since I'm not controlling the sending of it, do I? If it is the session doing it, maybe I can send a no-store header before I call session_start? Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to update all the computers, though, but I don't have to do the grunt work, at least. :) ---John Holmes... -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED]] Sent: Monday, October 07, 2002 11:22 PM To: [EMAIL PROTECTED] Cc: 'Tom Rogers'; [EMAIL PROTECTED] Subject: Re: [PHP] File download doesn't work with SSL Yes, you're right. You might want to turn off the forced SSL temporarily to debug this, if that's possible. Nothing other than your browser or the Web server will be able to show you the HTTP communication over SSL, because it's all trash to everything in between. There may be settings in Opera that can help you debug things; I'm not sure. I am not aware of any browser that does that for you, though it would be very handy. I wrote an HTTP proxy in PHP for my own use in such affairs. Email me if you would like to try it to see if it helps. Chris John W. Holmes wrote: You may find this very usefull: http://www.ethereal.com/ Wouldn't everything be encrypted, though, since it's over SSL? Including the headers? Unfortunately, the way they set up the server, it will not process any unsecured requests now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] File download doesn't work with SSL
Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] File download doesn't work with SSL
Why not just a simple wget -S https://... to see the headers? On Tue, 8 Oct 2002, Tom Rogers wrote: Hi, Tuesday, October 8, 2002, 1:32:16 PM, you wrote: JWH Thanks for the help guys. Like I said, the download works fine as long JWH as it's not over SSL. I will try to disable it and see if I can look at JWH the headers sent to see if a no-cache header is being sent, even though JWH I haven't specified it. Regardless, even if it is, I have no way of JWH stopping it, since I'm not controlling the sending of it, do I? If it is JWH the session doing it, maybe I can send a no-store header before I call JWH session_start? JWH Hopefully upgrading to SP2 for IE6 will fix this. It's a lot of work to JWH update all the computers, though, but I don't have to do the grunt work, JWH at least. :) Maybe this will help ? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, https://www.melbourneit.com.au/maintenance/;); curl_setopt ($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HEADER, 1); echo 'pre'; if(!curl_exec ($ch)){ echo 'Error: '.curl_error($ch).'br'; } echo '/pre'; curl_close ($ch); ? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file download/open and ie bug
I'm using version 6 of IE and Netscape I'm allowing the user to open/dowload a file from a secure locaiton on our server. Under Netscape it works great! Under IE, it doesn't work at all. IE complains about not being able to read from the server. Anyone know of any workarounds? here's the command I send: header(Content-type: {$mimetype[PDF]} \n); header(Content-transfer-encoding: binary\n); header(Content-length: . filesize($fname) . \n); readfile($fname);
[PHP] File download/upload
Hello, Can anyone point me towards a tute (or any info) about using php to upload and download medium size (~500k-1meg) files into a mySQL database (as blob's i assume). Cheers, Brad Nel vino la verità, nella birra la forza, nell'acqua i bacilli -- In wine there is truth, in beer there is strenght, in water there are bacteria -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file download in IE
Hi! How on earth do I make Internet Explorer to download a file generated with: header(Content-type: application/octet-stream); header(Content-Disposition: attachment; filename=$fname); include($this-dir . $fname); exit; It works on http but I need it on https and if I try to download it through https Internet explorer says it can't find the website.. after it asks me if I want to save the file. I have checked the page and it works with: netscape under windows and konqueror, galeon, netscape under linux. I have seen reports on the web about this feature of Internet explorer and they all say to download some service pack.. I have updated my internet explorer to the latest 6 version with all the updates on the web but it still does not work! Anyone knows a workaround for this? I don't want to do it with header (Location: somefile) because the file that I want to make available for download is outside the webroot and i want it to be accessible only through my script. Thanks a lot! Eagerly waiting for a response, Mihai -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file download in IE
I think this is only an issue with an un-patched IE5.01, anything higher than that should work fine. .b -Original Message- From: Negrea Mihai [mailto:[EMAIL PROTECTED]] Sent: 23 April 2002 12:26 To: [EMAIL PROTECTED] Subject: [PHP] file download in IE Hi! How on earth do I make Internet Explorer to download a file generated with: header(Content-type: application/octet-stream); header(Content-Disposition: attachment; filename=$fname); include($this-dir . $fname); exit; It works on http but I need it on https and if I try to download it through https Internet explorer says it can't find the website.. after it asks me if I want to save the file. I have checked the page and it works with: netscape under windows and konqueror, galeon, netscape under linux. I have seen reports on the web about this feature of Internet explorer and they all say to download some service pack.. I have updated my internet explorer to the latest 6 version with all the updates on the web but it still does not work! Anyone knows a workaround for this? I don't want to do it with header (Location: somefile) because the file that I want to make available for download is outside the webroot and i want it to be accessible only through my script. Thanks a lot! Eagerly waiting for a response, Mihai -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file download in IE
On Tue, 23 Apr 2002, .ben wrote: I think this is only an issue with an un-patched IE5.01, anything higher than that should work fine. In my experience, there're problems even with MSIE 6.x. Regards, Rodolfo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Download
Hey all. Im trying out a script that where I can download the contents of a database as a dump. On a large database, the end get truncated. ie, there were still maybe 6-7 more tables more till the end out of maybe 100 tables. The behaviour is erratic. It is not consistent with where the dump gets truncated. This is in the file if it means anything. header(Content-disposition: filename=database.sql); header(Content-type: application/zip); header(Pragma: no-cache); header(Expires: 0); I never used php to download files, before, so I haven't a clue. Merry Christmas all.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File download results question
Hi there. I have a small php app that allows a user to download a txt file that's created 'on the fly' from a database. Everything is working great except for the actual results displayed on the file...it get results similar to the code below...it's insertng br tags (and square characters) all over the place. Could someone tell me the name of the function that removes this? Thx Joe :) Delete from databaseBRphpBR//connect to db br / $connectionToDB = odbc_connect(codesnipits, joecode, joecode); br / br / -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File Download Inquiry
Hi there. How would I go about downloading a file off of the server. The filename will always be the same in my case. Say it is sitting in a directory called 'textfiles'. What method/function would I use to download it to a user's local system? Thx Joe:) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File Download Inquiry
You can just link to the file eg a href=yourfilenamehere.whatever_extdownload file/a just make sure the path is correct. Joe Van Meer wrote: Hi there. How would I go about downloading a file off of the server. The filename will always be the same in my case. Say it is sitting in a directory called 'textfiles'. What method/function would I use to download it to a user's local system? Thx Joe:) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File Download Mouse Behavior
When using PHP to generate a download file, the PHP program generates the headers and the actual text content of the file and this all works just fine. However, after the file download is complete, positioning the mouse anywhere over the browser (still showing the previous page) it appears as an hour glass, even though the mouse is active and still allows further clicks on the page. Has anyone come up with a method of cleaning up this behavior? Browser is IE on NT. Warren Vail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File Download IE behavior
When generating a download file from PHP to IE (Netscape is not used by my client base) the browser prompts with an option to download the file or open the file where it is. Opening the file fails and I am forced to download the file to my local drive before receiving another prompt to open the file where the second Open works just fine. Is there a way to allow this first open to work, or cause the open option on the first download window to be removed? Warren Vail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] File Download IE behavior
If you want it to automatically be saved to disk, send the header(Content-type: octet/stream); If there is a problem with the open I would think its on the client side since theres nothing mor the server can do but specify a content type. -Original Message- From: Warren Vail [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 11, 2001 7:50 AM To: [EMAIL PROTECTED] Subject: [PHP] File Download IE behavior When generating a download file from PHP to IE (Netscape is not used by my client base) the browser prompts with an option to download the file or open the file where it is. Opening the file fails and I am forced to download the file to my local drive before receiving another prompt to open the file where the second Open works just fine. Is there a way to allow this first open to work, or cause the open option on the first download window to be removed? Warren Vail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File download script
Hi all, I have a script getfile.php which when I call like getfile.php?fileid=12 and it returns the file to the browser with the appropiate mime headers etc.. however a problem has recently come where when I have a link to this from a page then it prompts me to download the page I'm calling from. if I then click open it then prompts me correctly.. any body got any idea? It never used to do this so something has changed TIA Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] file download
Hi everyone! I need user to dowload a file from my server ( Apache ), what i do is: ? header(Content-Type: application/download); header(Content-Disposition: attachment; filename='report.txt'); echo file contents; ? It was working till now but sudenly i start recieve the message from iexplorer: IE can not download ScriptName.php file from the server. IE was not able to open this site. The requested site either unavailable or can not be found. :( Does somebody knows what is going on? Thanks, Alexey. Email: [EMAIL PROTECTED] ICQ# 101975252 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] file download
Hello, I had the same problem as you for months! until someone post this a couple of weeks ago: header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=file.txt); include(file.txt); py - Original Message - From: Aleksey Yarilovets [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 23, 2001 9:44 AM Subject: [PHP] file download Hi everyone! I need user to dowload a file from my server ( Apache ), what i do is: ? header(Content-Type: application/download); header(Content-Disposition: attachment; filename='report.txt'); echo file contents; ? It was working till now but sudenly i start recieve the message from iexplorer: IE can not download ScriptName.php file from the server. IE was not able to open this site. The requested site either unavailable or can not be found. :( Does somebody knows what is going on? Thanks, Alexey. Email: [EMAIL PROTECTED] ICQ# 101975252 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] File Download With A Twist....
G'Day, I would like to do the following when a user clicks on a link to this PHP script. The script would be located on www.myserver.com but the page with the link would be on a mirror say in Australia (www.someserver.com.au): - Log info about the user download request to a text file - Display a page ("Thankyou for downloading . If you download does not start automatically. etc.) - Start a download of a file from a remote server based on the parameters to the script Eg: Suppose that the page on www.someserver.com.au contained the following link http://www.myserver.com/dnld.php?loc=aufile=somefile.zip - Log info about the user download request to a text file Write this info into a text file on www.myserver.com - Display a page ("Thankyou for downloading . If you download does not start automatically. etc.) Display the page in the user's browser - Start a download of a file from a remote server based on the parameters to the script Essentially initiate http://www.someserver.com.au/somefile.zip TIA -- Donovan E-Mail: [EMAIL PROTECTED] Web: www.edye.wattle.id.au "If I throw a stick will you go away?" "Very funny Scotty. Now beam down my pants!" GXExplorer - Freeware Delphi Windows Explorer Replacement and Delphi Components www.gxexplorer.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] File Download Completion
While we are on the subject, I made some tests with Apache logs and it seems that Apache writes the size of the file that you are DL to the log file at the beginning of the transfer. So if you are DL a 1MB file apache will write that you have DL a 1MB file and it doesn't reflect weather you stopped the DL in the middle. From it's point of view you asked for a 1MB file and you got it... so checking the log file will not work. berber -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 31, 2001 12:44 PM To: Php-General Subject: [PHP] File Download Completion Is it possible to find out if a client finished to DL a file? Suppose i put a link to a file and people start to DL the file. Some people can stop the DL in the middle. I need to know how many people completed the DL. Any simple ideas how to do this? thanks berber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File Download Completion
On Wednesday, January 31, 2001 at 12:00 PM, "Boaz Yahav" [EMAIL PROTECTED] wrote: Seems like your theory doesn't stand the reality test :) This is the script which for some reason works with Netscape but not with IE (it used to) : ignore_user_abort(0); $filename="test.gz"; $file="/home/examples/" . $filename; header("Content-Disposition: attachment; filename=$filename"); header("Content-Type: application/x-gzip"); header("Content-Length: ".filesize($file)); header("Pragma: no-cache"); header("Expires: 0"); /* $fp = fopen($file, "r"); if(!$fp) { echo"Can't open file for read"; exit(); } print fread($fp, filesize($file)); */ // readfile($file) does the same thing. echo"BRBRBRBRH1BThe file was downloaded successfully/B/H1BRBRBRBR"; For some reason it never shows the last echo weather i let the DL complete or stop it in the middle... Remember that everything you are sending to the browser -- whether it be by print, echo, readfile, or HTML code outside of ?PHP ... ?, becomes the file the user is downloading. If you were to open the gzip file you're sending, you'd notice that the "BRBRBRBRH1BThe file was downloaded/B successfully/B/H1BRBRBRBR" is being appended to the end of that file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File Download Completion
"Boaz Yahav" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is it possible to find out if a client finished to DL a file? Suppose i put a link to a file and people start to DL the file. Some people can stop the DL in the middle. I need to know how many people completed the DL. Any simple ideas how to do this? thanks berber One option could be to use ignore_user_abort: ?PHP ignore_user_abort(0); // Script will be aborted if transfer fails for whatever reason ? blahblahblahyaddityyaddiy yaddity ?PHP // If we're this far, it means the file's more or less transferred all the way. file_did_download(); ? Caveats with this: 1. Your file has to be part of the PHP page (though not neccessarily in the file itself, header("content-type: blah/blah"); combined with readfile($filename) will do the trick I think. 2. You (probably) can't use programs that are capable of resuming file transfers. If you can somehow, I have NO idea how it'll react. 3. If the user aborts right after the file_did_download() function is called but before the script actually terminates, things can go awry. I'm not entirely sure how this would be handled. -- - Daniel Grace http://dewin.oldbattery.com/ "Space may be the final frontier but its made in a Hollywood basement." - Red Hot Chili Peppers - Californication -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File Download Completion
Hi Berber, The only way I've figured this at the moment is to use the web server access logs. They will tell you how many bytes were transfered, if it matches the file size then transmission was potentialy succesful. I'm trying to think of a better way using PHP and maybe JavaScript but at the moment I've hit a brick wall. I'll have a think later and get back to you, but for your information it is possible. Regards, Andy Woolley www.databasewatch.com - Original Message - From: "Boaz Yahav" [EMAIL PROTECTED] To: "Php-General" [EMAIL PROTECTED] Sent: Wednesday, January 31, 2001 10:44 AM Subject: [PHP] File Download Completion Is it possible to find out if a client finished to DL a file? Suppose i put a link to a file and people start to DL the file. Some people can stop the DL in the middle. I need to know how many people completed the DL. Any simple ideas how to do this? thanks berber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] File Download Completion
I thought of this log thing but we are talking about logs that can be hundreds of MB per day. I'm talking about logs of a very big portal, starting to analyze this is useless :) thanks berber -Original Message- From: Andy Woolley [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 31, 2001 2:55 PM To: Boaz Yahav; Php-General Subject: Re: [PHP] File Download Completion Hi Berber, The only way I've figured this at the moment is to use the web server access logs. They will tell you how many bytes were transfered, if it matches the file size then transmission was potentialy succesful. I'm trying to think of a better way using PHP and maybe JavaScript but at the moment I've hit a brick wall. I'll have a think later and get back to you, but for your information it is possible. Regards, Andy Woolley www.databasewatch.com - Original Message - From: "Boaz Yahav" [EMAIL PROTECTED] To: "Php-General" [EMAIL PROTECTED] Sent: Wednesday, January 31, 2001 10:44 AM Subject: [PHP] File Download Completion Is it possible to find out if a client finished to DL a file? Suppose i put a link to a file and people start to DL the file. Some people can stop the DL in the middle. I need to know how many people completed the DL. Any simple ideas how to do this? thanks berber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] File Download Completion
Seems like your theory doesn't stand the reality test :) This is the script which for some reason works with Netscape but not with IE (it used to) : ignore_user_abort(0); $filename="test.gz"; $file="/home/examples/" . $filename; header("Content-Disposition: attachment; filename=$filename"); header("Content-Type: application/x-gzip"); header("Content-Length: ".filesize($file)); header("Pragma: no-cache"); header("Expires: 0"); $fp = fopen($file, "r"); if(!$fp) { echo"Can't open file for read"; exit(); } print fread($fp, filesize($file)); echo"BRBRBRBRH1BThe file was downloaded successfully/B/H1BRBRBRBR"; For some reason it never shows the last echo weather i let the DL complete or stop it in the middle... berber -Original Message- From: Daniel Grace [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 31, 2001 2:37 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] File Download Completion "Boaz Yahav" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is it possible to find out if a client finished to DL a file? Suppose i put a link to a file and people start to DL the file. Some people can stop the DL in the middle. I need to know how many people completed the DL. Any simple ideas how to do this? thanks berber One option could be to use ignore_user_abort: ?PHP ignore_user_abort(0); // Script will be aborted if transfer fails for whatever reason ? blahblahblahyaddityyaddiy yaddity ?PHP // If we're this far, it means the file's more or less transferred all the way. file_did_download(); ? Caveats with this: 1. Your file has to be part of the PHP page (though not neccessarily in the file itself, header("content-type: blah/blah"); combined with readfile($filename) will do the trick I think. 2. You (probably) can't use programs that are capable of resuming file transfers. If you can somehow, I have NO idea how it'll react. 3. If the user aborts right after the file_did_download() function is called but before the script actually terminates, things can go awry. I'm not entirely sure how this would be handled. -- - Daniel Grace http://dewin.oldbattery.com/ "Space may be the final frontier but its made in a Hollywood basement." - Red Hot Chili Peppers - Californication -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]