Uploadify からサーバーに送信されたファイル情報を処理するかなり単純なスクリプトがあり、サムネイルの作成以外はすべて機能します。私の間違いがどこにあるのか誰にもわかりますか?
<?php
session_start();
include "../_db.inc";
/*
Uploadify v3.1.0
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
$targetFolder = '/images/artist_pictures/'; // Relative to the root
$thumbsFolder = '/images/artist_pictures/thumbs/'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$yourid = (int)$_POST['yourid'];
$extension = end(explode(".", $_FILES['Filedata']['name']));
$filename = "artist_".$yourid.".".$extension;
$targetFile = rtrim($targetPath,'/') . '/' . $filename;
$targetThumb = rtrim($thumbsFolder,'/') . '/' . $filename;
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png','JPG','bmp'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
// CREATE THUMBNAIL
if($extension=="jpg" || $extension=="jpeg") {
$src = imagecreatefromjpeg($tempFile);
}
else if($extension=="png") {
$src = imagecreatefrompng($tempFile);
}
else {
$src = imagecreatefromgif($tempFile);
}
list($width,$height)=getimagesize($tempFile);
$newwidth=50;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$thumbname = $targetThumb;
if (file_exists($thumbname)) {
unlink($thumbname);
}
imagejpeg($tmp,$thumbname,100);
imagedestroy($src);
imagedestroy($tmp);
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>
前もって感謝します!コリン