シングルアップロードとマルチアップロードがあります。サイズが6MBのファイルで試してみると、単一のアップロードが機能します。
6MB のファイルに対して複数または 1 つの複数ファイルのアップロードを試みても、うまくいきません。
何か案は?タイムアウトを次のように設定してみました:
$messages = array();
$errors = array();
$upload_dir = '.';
if(isset($_FILES['file']['tmp_name'])){
//Number of uploaded files.
$num_files = count($_FILES['file']['tmp_name']);
//loop over array of files
for($i=0; $i<$num_files; $i++){
//check if there is a file in the array.
if(!is_uploaded_file($_FILES['file']['tmp_name'][$i])){
//echo $_FILES['file']['tmp_name'][$i].': Upload Failed!';
}else{
//echo $_FILES['file']['tmp_name'][$i].': Upload good!';
//lets insert the data into the DB.
$filename = stripslashes($_FILES['file']['name'][$i]);
$extension = getExtension($filename);
$description = $_POST['description'][$i];
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
//print error message
$error[$i] = $filename.': '.'Unknown file extension! ';
}
else
{
//get the size of the image in bytes
//$_FILES['image']['tmp_name'] is the temporary filename of the file
//in which the uploaded file was stored on the server
$size=filesize($_FILES['file']['tmp_name'][$i]);
//compare the size with the maxim size we defined and print error if bigger
if ($size > MAX_SIZE*1024)
{
//echo '<h1>You have exceeded the size limit of 100MB!</h1>';
$errors[$i]=$filename.': You have exceeded the size limit of 100MB';
}
//we will give an unique name, for example the time in unix time format
$time = time()+$i;
$image_name=$time.'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$newname='D:\\uploads\\'.$image_name;
//$newname=$image_name;
//we verify if the image has been uploaded, and print error instead
$copied = copy($_FILES['file']['tmp_name'][$i], $newname);
if (!$copied)
{
$messages[$i]= $filename.': '.'Copy unsuccessful!';
//echo 'Copy unsuccessful!';
}else{
$messages[$i]= $filename.': '.'Copy successful!';
//get image information here.
$fileInfo = getimagesize($newname);
$mySize = $fileInfo[0];
$mimetype = image_type_to_mime_type($fileInfo[2]);
$dimensions = $fileInfo[3];
savePhotoInfo($image_name,$dimensions, $description,$mySize);
createThumb('D:\\uploads\\', 'D:\\uploads\\thumbnails\\', '180',$image_name);
//echo 'Copy successful!';
}
}
}
}
echo 'Upload results:';
echo '<br />';
for($x=0;$x<count($messages);$x++){
echo $messages[$x];
echo '<br />';
}
echo 'Upload errors:';
echo '<br />';
for($x=0;$x<count($errors);$x++){
echo $errors[$x];
echo '<br />';
}
}