Knowledgebase

PHP Download Script Problems

Posted by kyriakos, 07-21-2008, 05:19 PM
I've tried some of the scripts on the manual page of readfile function of php on php.net for example: My problem is that even though the download works fine, no matter what browser i tried it with it doesnt show up the file size and consequently the users of my site cant know how far in a download they are or if they got the full file or not. I believe its a web server setting causing this since the code seems to work for others. anyone has any idea what might be causing this?

Posted by The Universes, 07-21-2008, 05:31 PM
You need to add a header for size:

Posted by kyriakos, 07-21-2008, 06:00 PM
i already do that (check the function above) still the same outcome.

Posted by The Universes, 07-21-2008, 07:09 PM
My bad, missed that. Why the: ob_clean erases the output buffer.

Posted by kyriakos, 07-22-2008, 05:30 AM
It was part of the script in www.php.net/readfile. I removed that line but i still have the same problem.

Posted by Unquantifiable, 07-22-2008, 09:42 AM
One of these headers might be the problem as they are not really needed and complicate the whole thing. Try removing Content-Description, Content-Transfer-Encoding, Expires and Pragma. Also, readfile is terribly inefficient since it loads the entire file in RAM and does not support HTTP range requests (resumes or download managers that use lots of connections). I could post some efficient code that works but I'm not allowed to yet (need 5 posts!)

Posted by kyriakos, 07-22-2008, 11:57 AM
every script i found for this job doesnt allow range requests. most of them are either based on readfile or sending the file in chunks (i used to use that method before but users were complaining that the downloads sometimes stopped without the whole file being sent. tonyhark could you send me a private message with it ?

Posted by kyriakos, 07-22-2008, 12:30 PM
ok the script here appears to take care of http_range headers http://w-shadow.com/blog/2007/08/12/...load-with-php/ the problem with such a script now is.. how would i know when the download was actually finished in order to increase my download counters? its pretty important to count 'actual' downloads than initiated downloads.

Posted by kyriakos, 07-22-2008, 06:09 PM
still even with that.. no size and aparently no resume since the size cant be found



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
HiVelocity down (Views: 664)
Start up questions (Views: 563)


Language:

Client Login

Email

Password

Remember Me

Search