目前的網址傳回408 - Request Timeout
如果是固定的,你是你這個簡單的代碼:
$url = 'http://f26.stream.nixcdn.com/6f4df1d8c248cf149b846c24d32f1c35/514e0209/PreNCT5/22-TaylorSwift-2426783.mp4';
$useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.3 Safari/533.2';
$file = __DIR__ . DIRECTORY_SEPARATOR . basename($url);
$fp = fopen($file, 'w+');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 320);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
echo curl_exec($ch);
var_dump(curl_getinfo($ch)); // return request information
curl_close($ch);
fclose($fp);
什麼結果命令一下,如果你替換變量是怎樣的?例如'回聲'
';'。另外,你知道PHP提供了對curl的支持,而不必使用exec /命令行:http://www.php.net/manual/en/curl.examples-basic.php – thaJeztah 2013-03-23 16:49:34它實際上工作,如果我把在他們的網址,但不是當我使用變量,而不是... – thevoipman 2013-03-23 17:18:36
試試這個方法:'exec(「curl -o」。$ fnctid「。」.mp4 \「」。$ mp4。「\ 「」);''我懷疑問題在於'.'後面的字符串中的變量 – thaJeztah 2013-03-23 17:21:51