Immediate help needed with file download via HTTP!
| From: | Tim Meader | Date: | Wed, 06 Dec 2000 21:01:53 +0000 |
| Subject: | Immediate help needed with file download via HTTP! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28986@lists.php.net to get a copy of this message | ||
Hello all. I am in charge of the setup of a simple file repository as an
alternative to sending huge file attachments via email. At first I started
off trying to get it working via FTP, but then became aware of the ability
for PHP to upload via the POST method. I've switched over the this, and the
uploading works perfectly. So for that matter does downloading EXCEPT for
downloading text or html files, which of course just display in the browser.
To combat this, I've attempted to use HTTP headers to initiate the file
downloads, but so far to no avail. My problem is that the download seems to
begin, but then just simply stops stating that the document contains no data.
If I check the directory I attempted to download to, it doesn't appear that a
file was ever even made to hold my download. The code I am using is below,
hopefully someone can offer some quick suggestions. And yes, I have searched
through the mailing list for answers to this exact problem, but haven't
seemed to be able to find anything. Thanks in advance for any and all help in
this matter.
$fp2 = fopen
("/usr/local/apache-ssl/htdocs/users/$directoryname/$filedirs[$i]/$uploadfile_name[$i].php",
"w");
fwrite($fp2, "<?php\n\n");
fwrite($fp2, "header(\"Content-Type:
application/force-download; name=\\\"$uploadfile_name[$i]\\\"\");\n");
fwrite($fp2, "header(\"Content-Transfer-Encoding:
binary\");\n");
fwrite($fp2, "header(\"Content-Length:
$uploadfile_size[$i]\");\n");
fwrite($fp2, "header(\"Content-Disposition: attachment;
filename=\\\"$uploadfile_name[$i]\\\"\");\n\n?>");
fclose($fp2);
Like I said, all the files are uploading to the server correctly, so I'm a
little dismayed by this.
--
Tim Meader
ACS GSG
tmeader@cne-odin.gsfc.nasa.gov