This is code I am working on. It is suppose to take a file and check then transfer it to the server in a directory called uploads. It works as far as checking the valid image types and sizes but when it checks to see if the image got to the server it echos the error message that the image was not recieved. I didn't see any problems in the code.
<?php
$target = "uploads/";
$target = $target . basename($_FILES['uploaded']['name']);
$ok=1;
if($uplaoded_size < 150000)
{
if($uploaded_type == "image/png")
{
$ok =1;
}
elseif($uploaded_type == "image/gif")
{
$ok =1;
}
elseif($uploaded_type == "image/jpeg")
{
$ok =1;
}
}
else
{
$ok =0;
}
// check if ok is 0. File not ready for uploading
if($ok ==0)
{
echo "Upload failed. Please make sure your file is of type JPEG, PNG or GIF and is smaller than 150.0 KB!";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The File was Uploaded: ". basename($_FILES['uploadedfile']['name']). "has been uploaded";
}
else
{
echo "File failed to upload please try again or contact us.";
}
}
?>