可能重複:
CURLOPT_FOLLOWLOCATION cannot be activated文件名空間? file_put_contents
我使用的是WordPress插件在我的WordPress網站上傳了一系列圖像。它總是工作正常,除非圖像網址中有空格。 我試過使用urlencode,但我仍然收到錯誤。這是它打破了代碼:
當我echo
出$img
它
"http://omodaimg.xcdn.nl/RM1000,1000/taupe-paul-green-sneakers-1157/PAUL GREEN/31024_1.png"
不帶引號。
foreach ($imgs as $img) {
$image_filename = wp_unique_filename($uploads['path'], basename(parse_url(trim($img), PHP_URL_PATH)));
$image_filepath = $uploads['path'] . '/' . $this->url_title($image_filename);
if (! file_put_contents($image_filepath, @file_get_contents(trim($img)))) {
if (! get_file_curl(trim($img), $image_filepath)) {
$logger and call_user_func($logger, sprintf(__('<b>ERROR</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), trim($img), $image_filepath));
unlink($image_filepath); // delete file since failed upload may result in empty file created
}
}
有人看到我沒有看到?非常感謝任何正確方向的提示。
錯誤說什麼? – F0G
警告:當啓用safe_mode或在/ home/...中設置了open_basedir時,curl_setopt():CURLOPT_FOLLOWLOCATION無法激活。但我不認爲這與它有任何關係。這是我在get_file_curl()被調用時得到的警告 – Martijn
@ user67510聽起來像您應該關閉安全模式。 –