Skip to content
Advertisement

curl get remote file and force download at same time

I’m trying to get a remote file and force download it to user at the same time. I can’t paste the code ,the code is too long . but the curl function works ,but the problem is it doesn’t out put anything till it gets the remote file first then it force downloads it to user.

I use this to tell curl to return a callback

JavaScript

now in my readCallback function I do this :

JavaScript

but it doesn’t return anything it just waits till fetching remote file is finished.

Advertisement

Answer

Try this, it will use curl to get the total size of the file then download partial chunks of the file proxying it to the user so as there is no wait for curl to download it first, I tested this with an avi,mp4,mp3 and an exe, hope it helps:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement