to pomoże
Kod PHP:
/** loop through the array of files ***/
for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++)
{
if(!empty($_FILES['userfile']['name'][$i])) {
if(($_FILES['userfile']['type'][$i] == "image/jpg") || ($_FILES['userfile']['type'][$i] == "image/jpeg") || ($_FILES['userfile']['type'][$i] == "image/png") || ($_FILES['userfile']['type'][$i] == "image/gif") || ($_FILES['userfile']['type'][$i] == "image/pjpeg")) {
// check if there is a file in the array
if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i]))
{
$messages[] = 'No file uploaded @';
}
// check the file is less than the maximum file size
elseif($_FILES['userfile']['size'][$i] > $max_file_size)
{
$messages[] = "File size exceeds $max_file_size limit";
}
else
{
// copy the file to the specified dir
if(move_uploaded_file($_FILES['userfile']['tmp_name'][$i],$_SERVER['DOCUMENT_ROOT'].$upload_dir.$_FILES['userfile']['name'][$i]))
{
/*** give praise and thanks to the php gods ***/
$messages[] = $_FILES['userfile']['name'][$i].' uploaded';
}
else
{
/*** an error message ***/
$messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed';
}
}
}
}
}