Results 1 to 7 of 7
Threaded View
-
18th Jun 2010, 03:03 PM #1OPThe Wise OneWebsite's:
twilight.ws ddlrank.com[PHP] Downloading a file with cURL
This thread is both a code snippet and a question.
Lets start with the code:
PHP Code:$url = "http://downloadwebsite.com/file_you_are_going_to_download.rar";
$out = fopen("./".trim(basename($url)), 'wb+'); //Opens the temp file in the local directory of your server, same filename as the file you are downloading
$ch = curl_init(); //initialize curl
curl_setopt($ch, CURLOPT_FILE, $out); //Set it to download the content to the file created previously
curl_setopt($ch, CURLOPT_HEADER, 0); //Depending on the website you are downloading from there are headers that need to be sent
curl_setopt($ch, CURLOPT_URL, $url); //Set the url you want to start curling :P
curl_exec($ch); //Do the magic
curl_close($ch); //Close the magic
fclose($out); //Close the downloaded file properly
On a server from a KWWH member this worked perfectly, but now all of a sudden, instead of downloading the file to the server, it displays the contents of the file in the browser, any ideas why this is happening?
Thanks allWhoo Reviewed by Whoo on . [PHP] Downloading a file with cURL This thread is both a code snippet and a question. Lets start with the code: $url = "http://downloadwebsite.com/file_you_are_going_to_download.rar"; $out = fopen("./".trim(basename($url)), 'wb+'); //Opens the temp file in the local directory of your server, same filename as the file you are downloading $ch = curl_init(); //initialize curl curl_setopt($ch, CURLOPT_FILE, $out); //Set it to download the content to the file created previously curl_setopt($ch, CURLOPT_HEADER, 0); Rating: 5I can always be contacted by sending a tweet @twilightws
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
downloading from file hosting links with FTP?
By Mitt281 in forum Web Application/Script SupportReplies: 1Last Post: 7th Nov 2012, 05:43 AM -
Curl url file (I need help)
By spanero in forum Web Development AreaReplies: 3Last Post: 22nd Dec 2011, 04:23 PM -
Looking for: HTTP File Downloading script
By CuraHack in forum Web Development AreaReplies: 4Last Post: 12th Apr 2011, 03:33 AM -
Downloading from torrents and uploading to file hosts - what to use?
By Cyberbob in forum Webmaster DiscussionReplies: 25Last Post: 11th Apr 2011, 08:07 AM -
Cant visit my home while downloading a file vps(kloxo)
By dark_horse in forum Server ManagementReplies: 5Last Post: 26th Jan 2011, 12:13 AM
themaRegister - register to forums...
Version 3.46 released. Open older version (or...