Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,311
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •