Re: Immediate help needed with file download via HTTP!
| From: | Chris Lee | Date: | Wed, 06 Dec 2000 21:13:45 +0000 |
| Subject: | Re: Immediate help needed with file download via HTTP! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28988@lists.php.net to get a copy of this message | ||
Im a little confused, are you trying to upload a file from the client to
the server or download a file from the server to the client ?
I think you got the upload working, but having a problem downloading the
file right?
<?
Header("Content-Type: image/jpeg ");
Header("Content-Disposition: filename='somefile' ");
readfile("/tmp/somefile");
?>
like this, works great for me. Ive used it for txt, html, jpeg, gif, and
pdf
If its uploading your having a problem with I'll write an example if you
want.
Chris Lee
Mediawaveonline.com
In article <00120616015301.29330@canyon.gsfc.nasa.gov>, "Tim Meader"
<tmeader@cne-odin.gsfc.nasa.gov> wrote:
> 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.
>
>