Due to the upload script I can not obtain the uploaded file by $_FILE variable, thefore I have to make do with
$file = file_get_contents("php://input")
I want to get the dimensions if it's an image, for that purpose, I would use getimageresize() but getimageresize() only take a file not a string. So that's my problem. How do i solve this?
$image = imagecreatefromstring($img_str);
$w = imagesx($image);
$h = imagesy($image);
A stream opened with php://input can only be read once; the stream does not support seek operations. However, depending on the SAPI implementation, it may be possible to open another php://input stream and restart reading. This is only possible if the request body data has been saved. Typically, this is the case for POST requests, but not other request methods, such as PUT or PROPFIND.
Try this
<?php
$imagesize = getimagesize($image_string);
echo 'Width: ' . $imagesize[0] . ' pixels<br />';
echo 'Height: ' . $imagesize[1] . 'pixels';
?>
I am using the function getimagesize()
. Have a look at the documentation on PHP.net: http://nl.php.net/manual/en/function.getimagesize.php