View Full Version : PHP file download

09-16-2011, 11:23 AM

I'm trying to create a script to download and save an audio file from another server via http.

I have written the script to extract the exact url of the audio files I'm looking to download, however the issue I'm not certain fopen can work with audio files or even how.

Also the size of these files may change and become very large depending on the situation. Does that cause any issues for PHP?

If it's not possible to use php for the file functions I plan on trying a shell script on a linux box, which brings yet another question, is it possible to use php to invoke or call up a shell script?

Thank you all in advance


09-16-2011, 11:53 AM
Hi Rob

fopen in theory will do the job just like file_get_contents or cURL but you might want to consider implementing pause / resume controls in case of a broken connection etc.

Also you may want to read the file from its source and write to disk by the Kb in a loop as if you're going to be downloading large files then you may exhaust the physical memory available to php and / or the server OS itself.

09-16-2011, 11:59 AM

Thanks for your reply, The pause and resume controls make sense, however I have honestly never used php to work with files before so I have no idea where to start. I'm going to do some research and see what I come up with to take your suggestions.

Thanks again