Hi thanks for reply,
here is my code, with file_get_contents which work perfectly for files with extensions like .pdf, .mp3 e.t.c,
error_reporting(E_ALL);
ini_set('display_errors', 1);
$url =urldecode(trim($_POST['url']));
$content = file_get_contents($url);
$name=basename($url);
$fp = fopen($name, "w");
fwrite($fp, $content);
fclose($fp);
echo "<a href='".$name."'>".$name."</a>";
and here is the curl code:
error_reporting(E_ALL);
ini_set('display_errors', 1);
$source = "http://website/file.php?id=123";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
$data = curl_exec ($ch);
$error = curl_error($ch);
curl_close ($ch);
$destination = "test.mp3";
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
In case of loading the curl script, it does not give any error, but writes a 0 byte file named test.mp3
what i want is, the code should work even for files which are not having extension meaning, which are called by id like for example,
http://website/file.php?id=123
so, i want to load this type of url in php script which can grab the file, if that is possible .