それで、uploadcare cdn にアップロードしようとすると、次のエラーが表示されます: Uncaught Exception: could't open file "ce3577f708f527ff570e0d21acb39c62.jpg"
$description = $_POST['uploaddesc'];
list($width,$height) = getimagesize($_FILES['uploadimage']['tmp_name']);
$extensions = array('image/jpeg','image/jpg','image/gif', 'image/png', 'image/tiff');
$move = 'uploads/';
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$extension = pathinfo($_FILES['uploadimage']['name']);
if(!$_FILES['uploadimage']['tmp_name']){
$errors[]="Please choose an image";
}
if(empty($description)){
$errors[]='Please choose a description for the image';
}
//IF IMAGE IS UPLOADED..
if($_FILES['uploadimage']['tmp_name']){
$mime = finfo_file($finfo, $_FILES['uploadimage']['tmp_name']);
// IF MIME FAILES OR GETIMAGESIZE IS NULL (画像がないことを意味します) if(!getimagesize($_FILES['uploadimage']['tmp_name']) && !in_array($_FILES['uploadimage']['tmp_name'] ,$mime)){ $errors[]='画像を選択してください'; unset($_FILES['uploadimage']['tmp_name']); }
if(empty($errors)){
$randString = md5(time()); //encode the timestamp - returns a 32 chars long string
$fileName = $_FILES["uploadimage"]["name"]; //the original file name
$splitName = explode(".", $fileName); //split the file name by the dot
$fileExt = end($splitName); //get the file extension
$newFileName = strtolower($randString.'.'.$fileExt); //join file name and ext.
if(move_uploaded_file($_FILES['uploadimage']['tmp_name'], $move . $newFileName)){
$description = $_POST['uploaddesc'];
$user->insertArt($description, 'uploads/' . $newFileName, $user->getUsername($_SESSION['username']));
$file = $api->uploader->fromPath('uploads/' . $newFileName);
$file->store();
//throw new ErrorException('MEMORY USAGE ' . memory_get_peak_usage());
}
}
}