Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-16-2011, 10:23 AM   PM User | #1
rwslippey
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rwslippey is an unknown quantity at this point
PHP file download

Hello,

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

Rob
rwslippey is offline   Reply With Quote
Old 09-16-2011, 10:53 AM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,667
Thanks: 46
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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.
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 09-16-2011, 10:59 AM   PM User | #3
rwslippey
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rwslippey is an unknown quantity at this point
TangoForce,

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

Rob
rwslippey is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:20 PM.


Advertisement
Log in to turn off these ads.