I have a page that lets you upload a picture for your profile. It takes this picture and puts it into a folder which is titled by corresponding usernames. For example for the username brendan it would go in the folder photos/brendan/imagegoeshere.
I created this code, which might not be totally secure, but I worked a few bugs out of it. I was wondering why when I try uploading a picture, it always tells me the last else in the code, even if I meet all the requirements, and if it is just a server upload issue, what could be some of the problems I am having.
<?
$target = 'photos/'.$username;
$target = $target . basename( $_FILES['upload']['name']) ;
if (($_FILES["upload"]["type"] == "image/gif")
|| ($_FILES["upload"]["type"] == "image/jpeg")
|| ($_FILES["upload"]["type"] == "image/jpg")
|| ($_FILES["upload"]["type"] == "image/png" )
&& ($_FILES["upload"]["size"] < 2000))
{
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target))
{
?>
<span class="style22">Your file has been uploaded sucessfully. To return to My Album click here.</span>
<?
}
else
{
?>
<span class="style22"><br><center>Sorry your file was not uploaded. Please hit the back button and try again. </center></span>
<?
}
}
else
{
?>
<span class="style22">Sorry, but the file must be less than 2 megabytes, and it must also be a .jpeg .jpg .gif or a .png. Please go back and upload another photo.</span>
<?
}
?>
O yea, $username is defined on the top of that same page, so it is a declared variable.