我试图从网址下载文件,当我使用浏览器下载对话框工作,但当我使用此代码时,我的服务器上的新文件保持为空.
$ch = curl_init(); $source = "https://myapps.gia.edu/ReportCheckPortal/downloadReport.do?reportNo=$row['certNo']&weight=$row['carat']"; curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); $destination = "./files/certs/$row['certNo'].pdf"; $file = fopen($destination, "w+"); fputs($file, $data); fclose($file);
网址示例:https://myapps.gia.edu/ReportCheckPortal/downloadReport.do? reportNo = 1152872617 & weight = 1.35