我遇到了一个我无法弄清楚的错误,我正在做的是我有一个字符串或一堆 url,我将它们放入一个数组中,然后循环数组并调整大小并上传图像,但我收到这个错误。任何帮助将不胜感激!
错误
file_get_contents(http://a513.phobos.apple.com/us/r1000/094/Purple/v4/d4/e4/02/d4e402a3-a485-4d4c-cf9b-90b0af391626/mzl.wbbwbbab.png )
[function.file-get-contents]: failed to open stream: HTTP request failed!
HTTP/1.0 400 Bad Request in "My File" on line 53
PHP
include("picture-resize.php");
$image = $_POST['thumbnail'];
$slug = $_POST['slug'];
$images = $_POST['screenshots'];
$list = explode(",", $images);
$listlength = count($list);
$i = 0;
$image = $_POST['thumbnail'];
$path = parse_url($image, PHP_URL_PATH);
$filename = $slug.'-'.$i;
$extension = pathinfo($path, PATHINFO_EXTENSION);
$file = $filename.'.'.$extension;
file_put_contents('../tmp/' . $file, file_get_contents($image));
$picture = new pic_resize();
$picture->load('../tmp/'.$file);
$picture->resizeToWidth(125);
$picture->save('../images/125x125/'.$file, $picture->image_type);
unlink('../tmp/'.$file);
$thumbnail = $file;
$new_list = array();
while($listlength > $i) {
$path = parse_url($list[$i], PHP_URL_PATH);
$extension = pathinfo($path, PATHINFO_EXTENSION);
$file = $filename.'.'.$extension;
file_put_contents('../tmp/' . $file, file_get_contents($list[$i]));
$picture = new pic_resize();
$picture->load('../tmp/'.$file);
$picture->resizeToWidth(640);
$picture->save('../images/640x320/'.$file, $picture->image_type);
$picture->resizeToWidth(310);
$picture->save('../images/310x205/'.$file, $picture->image_type);
unlink('../tmp/'.$file);
array_push($new_list, $file);
$i++;
}
$screenshots = implode($new_list, ',');