Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Programming Languages > PHP Development
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-21-2006, 12:31 AM
convinceme convinceme is offline
Junior Member
 
Join Date: Apr 2006
Posts: 1 convinceme is on a distinguished road
Default Problem with force download

While trying to make user download a file using headers the connection seems to be lost after a while so could someone please tell me how to work it out
http://www.chaska.com.pk/c1.php << here is the page with the following code
file size = 4.19 MB
connection is lost at around 1.91 MB using 64kps cable internet connection
PHP Code:
<?php 
set_time_limit
(0); 
header('Content-Description: File Transfer'); 
header("Content-type: audio/mpeg"); //mp3 contenttype 
header("Content-Disposition: attachment; filename=ek.mp3"); 
header('Content-length: '.filesize("ek.mp3")); 
    
readfile("ek.mp3"); 
?>

your help in this regard would be highly appretiated
Reply With Quote
  #2  
Old 12-06-2007, 01:06 PM
indy2kro indy2kro is offline
Junior Member
 
Join Date: Dec 2007
Posts: 1 indy2kro is on a distinguished road
Default

This usually happens because of the timeout. Every php is allowed to run only a small amount of time (by default 30 seconds). However, this is usually not enough when it comes to file download.

You can try to add this to your code: set_time_limit ( $seconds ) - where $seconds would be the amount you think it is safe for every user to download it.

However, that function is not available on all servers, especially if php is built in safe mode.

Last edited by indy2kro : 12-06-2007 at 01:08 PM.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 07:18 AM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.