hno Posted July 18, 2011 Share Posted July 18, 2011 HI, I need to write an script which download files from the input type .I have wrote a code but it first download the file's content then make the file with that content but something that I want to do is to download the video from the link and put that directly into the host without need to be downloaded into the user's computer something like leech. How can I do so ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/ Share on other sites More sharing options...
chintansshah Posted July 18, 2011 Share Posted July 18, 2011 Your requirements are not 100% clear, can describe in details. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244083 Share on other sites More sharing options...
hno Posted July 18, 2011 Author Share Posted July 18, 2011 Your requirements are not 100% clear, can describe in details. Sorry,English is not my native language , I need to write a script that get url from the user which is a url of a file then the script has to download that file to the host without need to download to the users computer For example the user enter :'www.test.com/test.flv" in the field then the script has to download that file and put it in 'www.mywebsite.com/test.flv' without downloading the video content in users computer and making the file again I mean the host should download the video not user . I hope I can say that clear. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244111 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 So basically you want your website to be able to steal content? file_get_contents might work. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244117 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 18, 2011 Share Posted July 18, 2011 are you tying to say video streaming? Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244121 Share on other sites More sharing options...
hno Posted July 18, 2011 Author Share Posted July 18, 2011 So basically you want your website to be able to steal content? file_get_contents might work. NOT actually, the problem of file_get_contents is that the php going to download the whole file's content so it takes some time to download the file but I want that the host do that I mean the host going to download the content not the user's computer Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244132 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 file_get_contents would load the contents to the server, not the client. It's going to take time to download no matter what, but if you really want to download something you might need to look into running a shell script that downloads a file. http://stackoverflow.com/questions/1834678/how-to-show-file-download-progress-in-php-shell-scripting If you are stealing other site content, I hope you get caught and burned. Otherwise, have a nice day. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244136 Share on other sites More sharing options...
hno Posted July 19, 2011 Author Share Posted July 19, 2011 file_get_contents would load the contents to the server, not the client. It's going to take time to download no matter what, but if you really want to download something you might need to look into running a shell script that downloads a file. http://stackoverflow.com/questions/1834678/how-to-show-file-download-progress-in-php-shell-scripting If you are stealing other site content, I hope you get caught and burned. Otherwise, have a nice day. Actually I have write that with file_get_contents :this is the line: file_put_contents($img, file_get_contents($url)); which $img is the name of the file to be created and the $url is the url which we are going to download I read about file_get_contents and it was mentioned that it Reads entire file into a string so It must be client side not server side because When it reads the file into a string , we have downloaded the file content into user's computer . But I want to be server side and the user does not have to download the content of the file something like leech websites that just show the progress and nothing is going to downloaded into user's computer Thanks all Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244424 Share on other sites More sharing options...
dcro2 Posted July 19, 2011 Share Posted July 19, 2011 Just, no. PHP is a server side processor. Everything happens on the server unless you decide to output the file to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244427 Share on other sites More sharing options...
hno Posted July 19, 2011 Author Share Posted July 19, 2011 Just, no. PHP is a server side processor. Everything happens on the server unless you decide to output the file to the browser. so ,something is wrong with my code?because every time if the user's want to download a file with more than 10MB it would take so long and in many cases it would never be complete and some times even the website is hang.Why is that?I'm using this code "file_put_contents($img, file_get_contents($url));" for making downloading the file .Is there any other way to download the file faster ,I mean really faster with the speed of the server? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244428 Share on other sites More sharing options...
dcro2 Posted July 19, 2011 Share Posted July 19, 2011 You're probably exceeding the default timeout of 30 seconds. See set_time_limit. You can't really speed it up any more than it is. Maybe curl might help. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244431 Share on other sites More sharing options...
hno Posted July 19, 2011 Author Share Posted July 19, 2011 You're probably exceeding the default timeout of 30 seconds. See set_time_limit. Is this taking more than 30 seconds for downloading a 10MB file? Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244432 Share on other sites More sharing options...
chintansshah Posted July 19, 2011 Share Posted July 19, 2011 hello hno, Can you do file_put_contents operation offline, like as per your requirements, create a cron job and update your files using file_put_contents. So when client is trying to download, a file creation time get reduced and client should not wait for the time. I hope you are clear with above solutions. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244438 Share on other sites More sharing options...
hno Posted July 19, 2011 Author Share Posted July 19, 2011 hello hno, Can you do file_put_contents operation offline, like as per your requirements, create a cron job and update your files using file_put_contents. So when client is trying to download, a file creation time get reduced and client should not wait for the time. I hope you are clear with above solutions. Hi my friend, No , I can't . I have to make the file right after downloading.Is there any other way to do that? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244441 Share on other sites More sharing options...
TeNDoLLA Posted July 19, 2011 Share Posted July 19, 2011 You do realize that if you are making it to download from host to host there can be bandwidth limitations between the hosts. And depending on the file size it can take long time. And for the user, this will show just loading page during the time it moves the filedata. Which will be uber gay, say to wait for 5mins for a page load. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244442 Share on other sites More sharing options...
hno Posted July 19, 2011 Author Share Posted July 19, 2011 You do realize that if you are making it to download from host to hos there can be bandwidth limitations between the hosts. And depending on the file size it can take long time. Bandwidth limitation is not a case.But you know for downloading a 10MB file from host to host It should not take so long in the other word more than 1 min. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244445 Share on other sites More sharing options...
TeNDoLLA Posted July 19, 2011 Share Posted July 19, 2011 Exactly should not, but can. And even if it was 1min, I would've personally closed my browser already at 20sec at most. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1244446 Share on other sites More sharing options...
teynon Posted July 20, 2011 Share Posted July 20, 2011 I just reread this and I dont know if this is what you're getting at or not... You want to copy the file from another server... To your server. That way the user can still see the file without downloading it. If this is the case... Hummm... It is pointless. Especially with video, unless you are streaming it. If they are watching the video in the web browser, they are still downloading it. They are just downloading it to their temporary files directory. Quote Link to comment https://forums.phpfreaks.com/topic/242249-need-help-with-direct-download-to-host/#findComment-1245396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.