Danny620 Posted February 7, 2011 Share Posted February 7, 2011 Right i have a file called file_download.php this file sends a zip file to the header what i want to do is download this zip file sent to header using curl i have code but when i run it it creates the zip but with 0 btyes <?php require_once '../includes/config.inc.php'; if(isset($_POST['update'])){ $url = 'http://www.northplanet.co.uk/updates/download_file.php'; $path = '408199.zip'; $fp = fopen($path, 'w+'); $curl = curl_init($url); curl_setopt($curl, CURLOPT_USERPWD, "smm-updates:nintendo"); curl_setopt($curl, CURLOPT_POSTFIELDS, "access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&update=1"); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_FILE, $fp); $data = curl_exec($curl); curl_close($curl); fclose($fp); $url = BASE_URL . 'install/'; // Define the URL. header("Location: $url"); exit(); // Quit the script. } ?> and this one which sends zip to header <?php //----------------------------Social Media Manager Version----------------------- // Important Info ~~ Do not touch unless advised to | // access_key ~~ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | // Pervious Version ~~ 1.0.2 - 14:00 - 07/02/2010 - Northplanet Ltd | // Next Version Release ~~ 1.0.4 ////////////////////////////////////////////////| //---------------------------- Version 1.0.3 - 19:00 - 07/02/2010 - Northplanet Ltd ----------------------------------------------------------------------------------- $version = '1.0.3'; $access_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; if(isset($_POST['access_key']) && $_POST['access_key'] == $access_key){ if(isset($_POST['update']) && $_POST['update'] == '1'){ // Location of updates file: define ('UPDATES', '/home/site/northplanet.co.uk/public_html/updates/'); $file = '408199.zip'; // Full update path: $update = UPDATES . $file; // Check that the image exists and is a file: if (file_exists ($update) && (is_file($update))) { // Make sure it has an .zip extension: $ext = strtolower ( substr ($file, -4)); if (($ext == '.zip')) { // Set the name as this image: $name = $file; } // End of $ext IF. } // End of file_exists() IF. // Get the image information: $info = getimagesize($update); $fs = filesize($update); // Send the content information: header ("Content-Type: {$info['mime']}\n"); header ("Content-Disposition: inline; filename=\"$name\"\n"); header ("Content-Length: $fs\n"); // Send the file: readfile ($update); }//END OF UPDATE if(isset($_POST['version']) && $_POST['version'] == '1'){ $arr = array ('version'=>$version); echo json_encode($arr); } }//END OF ACCESS_KEY ?> Link to comment https://forums.phpfreaks.com/topic/227003-curl-download-header-file-will-pay-%C2%A34500-if-you-can-fix/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.