Forum Moderators: coopster

Message Too Old, No Replies

help with user download

         

xeno439

1:22 am on Jul 9, 2005 (gmt 0)

10+ Year Member



can someone explain to me the code to put in a new page that forces a download of a file. I am new so go easy please (you might need to spell out what goes inside the variables etc.) I have tried a few examples and the file that downloads has the right name but the material on the file is filled with:

<br />
<b>Warning</b>: filesize(): Stat failed for fmailtxt (errno=2 - No such file or directory) in <b>/home/xeno/public_html/fmaildownload.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/xeno/public_html/fmaildownload.php:4) in <b>/home/xeno/public_html/fmaildownload.php</b> on line <b>4</b><br />
<br />
<snip>snipped other "headers already sent" lines<snip>
<b>Warning</b>: readfile(fmailtxt): failed to open stream: No such file or directory in <b>/home/xeno/public_html/fmaildownload.php</b> on line <b>10</b><br />

Thanks for help. btw I have no white spaces and the code is on a new page. I don't know what is wrong.

[edited by: coopster at 10:13 am (utc) on July 9, 2005]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

coopster

10:50 am on Jul 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, xeno439.

In order to *force* a download you need to send the browser the appropriate header [php.net](s). It seems you are getting a WARNING message pushed to the browser before your headers and therefore you are receiving the header errors.

You are going to need to fix that filesize function on line 4 before you will get to the next step. Looks like the file is not being found. Maybe you want to check for the file existence (is_file [php.net] and/or file_exists [php.net]) before trying to get it's size?