Jump to content

Downloads and headers


0xD34DB33F

Recommended Posts

Hi !

 

I am currently trying to develop a PHP application in which my server downloads a file and the user can do the same almost simultaneously. I already think about the problem "If the user downloads fastly than the server...", but it's not a problem at this moment.

To do so, I used the header and readfile functions of php. Here is my code :

 

header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="'.$data['name'].'";'); 
header('Content-Transfer-Encoding: binary'); 
header('Content-Length: '.$data['size']);
readfile($remoteFile);

 

I must to use the Content-length header to set the proper size of the file and not the size that is downloaded when the user clicks on the link. However, after some seconds or minutes, download is stopped and I need to restart...

If you think about a solution, even if it didn't use the header(); function, please tell me.

 

Thank you in advance...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.