Debugging 101.
PHP Code:
if (!($_FILES['file_up'][type] =="image/jpeg" OR $_FILES['file_up'][type] =="image/gif"))
{
## FIRST DEBUGGING CODE ADDED
$msg .= "<p>The reported file type is: " . $_FILES['file_up'][type] . "<br/>" ;
## END FIRST DEBUGGING CODE
$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";
}
This will print "The reported file type is :" , ie $_FILES['file_up'][type] is BLANK.
Why? Further investigation...Check the entire $_FILES array
PHP Code:
if (!($_FILES['file_up'][type] =="image/jpeg" OR $_FILES['file_up'][type] =="image/gif"))
{
## SECOND DEBUGGING CODE ADDED
foreach( $_FILES['file_up' ] as $k => $v ){
$msg .= "$k => $v <br />" ; }
## END SECOND DEBUGGING CODE
$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";
}
This gives :
Code:
jpgname => Chopin.jpg
type =>
tmp_name =>
error => 2
size => 0
What is error code 2? (0 is normally 'OK'). Go to Google and find...
Code:
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
Aha! File too big. How big is too big?
HTML Code:
<input type="hidden" name="MAX_FILE_SIZE" value="500" /><
500?
Edit/Add...
Your test
PHP Code:
if (!($_FILES['file_up'][type] =="image/jpeg" OR
$_FILES['file_up'][type] =="image/gif"))
isn't too good either. The type on jpeg is often ( ie, IE) reported as "image/pjpeg". Better to test for extensions or test the type with a regular expression.