"Daniel Doman" <dd****@panix.com> wrote in message
news:Xn****************************@166.84.1.69...
I suppose you can do the print( fread()) statement, but it doesn't
sound right to me. I am always uncomfortable with using the return value of
a read statement without validation. You are taking the return value of
your fread() which SHOULD be the entire contents of the file and
passing that on as an input value to your print statement. You aren't
validating the results of your fread(). Also, and this is just my opinion, I
don't think you should be using using print() to output binary values.
If you think about it, you are abusing PHP a lot. You are reading a
file of some size - probably a BIG one into php memory and then printing
it back out - again without validation. Why bother?
This is what fpassthru() is for: It will output to the stream, close
the file for you and let you know if there is a problem. i.e.. give you
validation!
To test your results. Don't try to open the file.. Do a Diff between
the source file and the downloaded file. The header information won't be
in the file.
I assume that you have some reason that you don't want to make the
file available as a simple href? I guess doing a force-download is cool,
but is that the only reason?
Hi Dan,
thanks for the info. I am new to PHP and am still learning the ropes.
For this file download, users go to page where they supply their email
address and then are redirected to the download page.
Being new to PHP, I was wondering if you could give me an example of
file downloading using fpassthru().
I was thinking of ftp'ing the file but am not sure how to do that
either!! (I get as far as connecting to our ftp server, but the file
can't be found ("No such file or directory" error). I used ftp_get())
I appreciate your input and assistance.