由於某種原因,使用此代碼時,它輸出的文件被稱爲「.jpg」。不能得到PHP以正確的名稱保存文件名
<?
$title = $GET['title'];
$url = $GET['url'];
$ourFileName = $title.jpg;
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
$ch = curl_init ("http://www.address.com/url=$url");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
$fp = fopen("images/$ourFileName",'w');
fwrite($fp, $rawdata);
fclose($fp);
echo ("<img src=images/$ourFileName>");
?>
很確定它與聲明$ ourFileName有關,任何幫助將不勝感激。