<?
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/content/upload/';
$uniqid = uniqid();
$extention = substr(basename($_FILES['afile']['name']), strrpos(basename($_FILES['afile']['name']), '.') + 1);
$uploadfile = $uploaddir . $uniqid . '.' . $extention;
if (move_uploaded_file($_FILES['afile']['tmp_name'], $uploadfile)) {
$AAA = $_SERVER['DOCUMENT_ROOT'].'/content/upload/'.$uniqid.'.'.$extention;
$img = new Imagick($AAA);
$orientation = $img->getImageOrientation();
switch($orientation) {
case imagick::ORIENTATION_BOTTOMRIGHT:
$img->rotateimage("#000", 180); // rotate 180 degrees
break;
case imagick::ORIENTATION_RIGHTTOP:
$img->rotateimage("#000", 90); // rotate 90 degrees CW
break;
case imagick::ORIENTATION_LEFTBOTTOM:
$img->rotateimage("#000", -90); // rotate 90 degrees CCW
break;
}
$img->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
$img->writeImage($AAA);
$img->clear();
$img->destroy();
echo '/content/upload/'.$uniqid.'.'.$extention;
} else {
}