使用以下代码:
$file = fopen('php://input', 'r');
$temp = tmpfile();
$imageSize = stream_copy_to_stream($file, $temp);
$imageDimensions = getimagesize($file); // Error here
$imageInfos = pathinfo($_GET['selected-image']);
我收到这个错误
getimagesize() expects parameter 1 to be string, resource given
因为$file
是 的资源fopen
。如果我不能读php://input
两次,我怎么能有一个资源和一个字符串?
更新
我试过这个:
$file = fopen('php://input', 'r');
$tempName = tempnam(sys_get_temp_dir(), '.upload');
$imageSize = fwrite(fopen($tempName, 'w+'), stream_get_contents($file));
$imageDimensions = getimagesize($tempName);
$imageInfos = pathinfo($_GET['selected-image']);
// Unlinks and other stuffs
错误:
Notice: getimagesize() [function.getimagesize]: Read error! in
谢谢!