当我上传一个文件(.jpg)并执行一个操作时,var_dump($_FILES['img'])
我会得到如下信息:
array
'name' => string 'help_clip_image020.jpg' (length=22)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string '/tmp/phpfa9gSr' (length=14)
'error' => int 0
'size' => int 35504
但是,使用此代码:
include("resize-class.php");
// *** 1) Initialise / load image
$resizeObj = new resize($_FILES['img']);
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> resizeImage(200, 200, 'crop');
// *** 3) Save image
$resizeObj -> saveImage('sample-resized.jpg', 100);
我会得到一个黑色填充的图像。但有一个绝对路径,如:
$resizeObj = new resize('http://leandrovieira.com/projects/jquery/lightbox/photos/image1.jpg');
一切正常。所以我的问题是:我需要在转换之前将图像存储在主机中吗?我想避免这种情况,因为我只需要缩略图。
另外: $_FILES['img']['tmp_name']
没有解决问题。