Every time I upload an image, even if I leave the field blank or upload the right file, I always get the error for incorrect file type :S
So if the file is left blank, it is still getting past the first if :SPHP Code:elseif($_GET["act"] == "profilepic")
{
$max = "10000000";
$file = $_FILES ["file"] ["name"];
$type = $_FILES ["file"] ["type"];
$size = $_FILES ["file"] ["size"];
$tmpname = $_FILES ["file"] ["tmp_name"];
$info = getimagesize ( $tmpname );
$re1 = '(image)';
if($file != "" || $size < $max)
{
if (preg_match ( "/" . $re1 . "/is", image_type_to_mime_type ( $info [2] ) )) {
$tempname = $_FILES ["file"] ["tmp_name"];
$file_spaces = uniqid ( "img" ) . $_FILES ["file"] ["name"];
$name = str_replace ( " ", "_", $file_spaces );
move_uploaded_file ( $tempname, "/home/habbcr/public_html/djpanel/djpics/$name" );
mysql_query ( "UPDATE `users` SET `picture` = '$name' WHERE `username` = '$username'" );
notice("Profile Picture Updated!");
echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"8;URL=?view=changedetails\">Your new profile picture has now been uploaded. You are now being taken back to the \"change Your Details\" form<br /><br />If you'd prefer not to wait, please click <a href=\"?view=changedetails\">Here</a>");
endnotice();
} else {
notice("Incorrect File Type");
echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"8;URL=?view=changedetails\">The file you tried uploading is <b>NOT</b> an image file. You are now being taken back to the \"change Your Details\" form<br /><br />If you'd prefer not to wait, please click <a href=\"?view=changedetails\">Here</a>");
}
}
else
{
notice("Error uploading file");
echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"8;URL=?view=changedetails\">There was an error uploading your file. You are now being taken back to the \"change Your Details\" form<br /><br />If you'd prefer not to wait, please click <a href=\"?view=changedetails\">Here</a>");
}
}
Moved by Invent (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks.





.
Reply With Quote





.



