Downloading multiple files from remote location with progress bar
I need to implement a feature where a user can paste one or more YouTube links, a PHP script then downloads all of them to the server, displays progress bar for each download and then inserts relevant information about them to database.
How should I go about implementing this... Is this achievable with just file_get_contents()? Or perhaps I should use cURL? And how would I implement the progress bar for each download process? I was thinking if you could do this with jQuery somehow.
Help appreciated. Thanks.
edit: Just for clarification: I do not need to know how to d开发者_如何学Cownload a video from YouTube, just how to download multiple files and how to display a progress bar for each download.
edit2: To elaborate: The site is an archive site for an artist. If a video file, such as an interview or live performance doesn't already exist on the site, but exists on YouTube, the user can simply paste a link to this video file, the server then downloads this file to the server and from that point on it's archived and hosted on the server and then people can watch the videos on the site. I just need to know how to download multiple files simultaneously and display a progress bar for each download so that the user(s) can see when they're ready to be viewed.
You'll have to do this with cURL, as an AJAX call would not work across domains.
I would post the information to a script file via AJAX, cURL the file, and echo numbers to represent the progress until it is finished. That would require multiple AJAX calls to get a true progress indicator, but it would probably be easier to just use a static spinner and call it a day.
You could send another AJAX call when the file is uploaded to the same PHP file to make your database changes as well.
精彩评论