Hi
Im currently having trouble trying to copy a file across from one server to another.
I can type the url in the browser (ie or firefox) or put it in a download manager (nettransport) and the file will start downloading, however when i use fopen OR fsockopen OR cURL to access the file, it returns a 404 error.
The file itself is 23823054 bytes (23.8mb) and the url is http://clipserver.net/bboyworld/rotady/Matchoneskill.wmv
I do not have access to the remote server myself, so i cannot change any settings on their side. The scripts i have tried using are:
// Using fsockopen
$fp2 = @fopen('matchoneskill.wmv', "w");
$fp = fsockopen('clipserver.net', 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
}
else {
$out = "GET /bboyworld/rotady/Matchoneskill.wmv HTTP/1.1\r\n";
$out .= "Host: clipserver.net\r\n";
$out .= "Accept: /\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)\r\n";
$out .= "Connection: Keep-Alive\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$str = fgets($fp, 128);
fwrite($fp2, $str);
}
fclose($fp);
}
fclose($fp2);
// Using cURL
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)";
// Start the output buffer (to suppress any errors)
ob_start();
// Initialise the curl
$ch = curl_init('http://clipserver.net/bboyworld/rotady/Matchoneskill.wmv');
// Set the user-agent
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
// Set the referer
curl_setopt($ch, REFERER, '');
// Exclude the header
curl_setopt($ch, CURLOPT_HEADER, 0);
// Excecute and fetch result
$okay = curl_exec($ch);
// Close the curl
curl_close($ch);
// Get the result from the buffer
$curl_result = ob_get_contents();
// Clean the buffer
ob_end_clean();
$fp2 = @fopen('newfile.wmv', "w");
fwrite($fp2, $curl_result);
fclose($fp2);
Each file saves a 404 error
Can anyone please help?