Edit: I learned something today about !!
from The Blue Dog (comment)
, thanks for the added PHP quirk ;-)
"Believe it or not, !! is the same as not having them there in the first place, try it and see: $t = true; if(!! $t){ echo "true";}" // The Blue Dog
Change this line:
if ( !!$_FILES['file']['tmp_name'] ) // is the file uploaded yet?
to
if ( $_FILES['file']['tmp_name'] ) // is the file uploaded yet?
and it will work. (tested)
Both !!
should not be there.
<?php
//Upload the image
$allow = array("jpg", "jpeg", "gif", "png");
$todir = 'images/';
if(isset($_POST['submit'])){
// if ( !!$_FILES['file']['tmp_name'] ) // is the file uploaded yet?
if ( $_FILES['file']['tmp_name'] ) // is the file uploaded yet?
{
$info = explode('.', strtolower( $_FILES['file']['name']) ); // whats the extension of the file
if ( in_array( end($info), $allow) ) // is this file allowed
{
if ( move_uploaded_file( $_FILES['file']['tmp_name'], $todir . basename($_FILES['file']['name'] ) ) )
{
echo "Success";
}
}
else
{
// error this file ext is not allowed
echo "Sorry, this is now allowed.";
}
}
}
// echo "however this works perfectly";
?>