Excluding $_FILES error number 4
Posted: Wed Dec 07, 2011 1:12 pm
Hi Everyone,
I have a rather stupid question, but I haven't been able to find the correct method / syntax to do this. I want to allow users to upload a maximum of 5 photos - less then 5 is OK too. I've been testing the following script and haven't gotten it to ignore error # 4 (no file uploaded):
I will be using a while loop and incrementing through the script (this is simpler version). Does anyone know the proper syntax for the IF statement:
"if ($_FILES['userfile']['error'] == 1 || 2 || 3 || 6 || 7)" ?
Thanks much,
Rick
I have a rather stupid question, but I haven't been able to find the correct method / syntax to do this. I want to allow users to upload a maximum of 5 photos - less then 5 is OK too. I've been testing the following script and haven't gotten it to ignore error # 4 (no file uploaded):
Code: Select all
if ($_FILES['userfile']['error'] == 1 || 2 || 3 || 6 || 7) {
echo 'Problem: ';
switch ($_FILES['userfile']['error']) {
case 1: echo 'File exceeded upload_max_filesize';
break;
case 2: echo 'File exceeded max_file_size';
break;
case 3: echo 'File only partially uploaded';
break;
case 6: echo 'Cannot upload file: No temp directory specified.';
break;
case 7: echo 'Upload failed: Cannot write to disk.';
break;
}
exit;
}"if ($_FILES['userfile']['error'] == 1 || 2 || 3 || 6 || 7)" ?
Thanks much,
Rick