rendered paste body<?php
$max_filesize = 3 * 1024 * 1024;
$allowed_extensions = array (0 =>"jpeg", 1=>"doc", 2=>"pdf", 3=>"xls");
print_r($_SERVER);
for ($i = 0; $i < 4; $i++)
{
//error == 4 means the user is trying to upload an empty field.
if ($_FILES['file'.$i]['error'] == 4) {
echo "Skipping file #", $i, ", because it's empty";
continue;
}
else {
//storing filesize
$filesize = $_FILES['file'.$i]['size'];
//getting the filename and the extension.
list ($filename, $extension) = explode(".", $_FILES['file'.$i]['name']);
if ($filesize > $max_filesize) {
echo "The file size is way too big, skipping file #", $i;
continue;
}
else {
if (strcmp($extension, $allowed_extensions[$i]) != 0) {
echo "File extension is invalid, skipping file #", $i;
continue;
}
else {
echo $_SERVER['DOCUMENT_ROOT'].$filename;
}
}#endif
}#end if
}#end forloop.
?>