naik.apoorv Posted November 6, 2010 Share Posted November 6, 2010 Hey guys I m developing a download system for my server that reads files from a third party server and enables MY USER to download it via my URL. What mechanisms should i use to manage this efficiently ??? file_get_contents(); fopen(); Or should I use some kind of buffer mechanism ??? Please do provide a code sample as I'm stuck here very badly. Note: The file sizes may be >500MB Quote Link to comment https://forums.phpfreaks.com/topic/217928-reading-a-file-from-remote-server-and-returning-the-content/ Share on other sites More sharing options...
Adam Posted November 6, 2010 Share Posted November 6, 2010 Will it be the same file downloaded multiple times, or multiple files downloaded once? If the latter you're probably going to struggle with this as you can't 'stream' files through a browser like that. Your server would have to download the >500MB file prior to allowing the user to download it. Dependent on your server's connection speed and how many users will be downloading at once, it could be a long wait. If it's the same file however, or several that are frequently used, I'd download a cached version periodically to your own server. Quote Link to comment https://forums.phpfreaks.com/topic/217928-reading-a-file-from-remote-server-and-returning-the-content/#findComment-1131020 Share on other sites More sharing options...
naik.apoorv Posted November 6, 2010 Author Share Posted November 6, 2010 Will it be the same file downloaded multiple times, or multiple files downloaded once? If the latter you're probably going to struggle with this as you can't 'stream' files through a browser like that. Your server would have to download the >500MB file prior to allowing the user to download it. Dependent on your server's connection speed and how many users will be downloading at once, it could be a long wait. If it's the same file however, or several that are frequently used, I'd download a cached version periodically to your own server. Only a single file is to be downloaded at a time. Figuring out the problem of buffering, I had an idea of linking the download page to the file on remote server. " When the user accesses the download page it directly uses the remote file link in the header attachment ". Whether it would work ? I have not tried though but maybe I will be up with the code today for testing. Quote Link to comment https://forums.phpfreaks.com/topic/217928-reading-a-file-from-remote-server-and-returning-the-content/#findComment-1131078 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.