我在上传简单的图片时遇到问题。我已经尝试过,只有在添加图像调整大小功能后,上传部分才能完美地工作,但会出现未知错误。
public function post_add_image()
{
\Upload::process(array(
'path' => '../images/',
'normalize' => true,
'change_case' => 'lower',
'randomize' => true,
'ext_whitelist' => array('jpeg', 'jpg', 'gif', 'png'),
'max_size' => 1024 * 1024,
));
if (!\Upload::is_valid()) {
return $this->response(\Upload::get_errors());
} else {
foreach (\Upload::get_files() as $file) {
// Here comes ERROR
$image = Image::load($file['file'], false, $file['extension']);
$image->crop_resize(800, 600);
$image->save('test');
}
}
//\Upload::save();
return $this->response(\Upload::get_files());
}
和错误:
RuntimeException [错误]:库不支持 /tmp/phpOnZReS 的这种文件类型。
COREPATH/classes/image/driver.php@line
我制作了上传文件的 var_dump:
array(10) {
["name"]=>
string(27) "crunchbang-logo-minimal.png"
["type"]=>
string(9) "image/png"
["error"]=>
bool(false)
["size"]=>
int(278)
["field"]=>
string(10) "pictures:0"
["file"]=>
string(14) "/tmp/phpDdTLwJ"
["errors"]=>
array(0) {
}
["extension"]=>
string(3) "png"
["filename"]=>
string(23) "crunchbang-logo-minimal"
["mimetype"]=>
string(9) "image/png"
}