Hi I have got the following code. I am trying to upload an image with a unique name by using the tempnam
function.
$upfile = tempnam('client_images', '');
unlink($upfile);
//move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile);
if($_FILES["userfile"]["type"] != "image/gif" && $_FILES["userfile"]["type"] != "image/pjpeg" && $_FILES["userfile"]["type"] != "image/png" && $_FILES["userfile"]["type"] != "image/jpeg")
{
echo "ERROR: You may only upload .jpg or .gif or .png files";
}
else
{
if(!move_uploaded_file($_FILES["userfile"]["tmp_name"],$upfile))
{
echo "ERROR: Could Not Move File into Directory";
}
else
{
echo "Temporary File Name: " .$_FILES["userfile"]["tmp_name"]."<br />";
echo "File Name: " .$_FILES["userfile"]["name"]."<br />";
echo "File Size: " .$_FILES["userfile"]["size"]."<br />";
echo "File Type: " .$_FILES["userfile"]["type"]."<br />";
}
}
?>
However for some reason I cannot see these images in my client_images
folder.
The output looks like this:
Temporary File Name: C:\Windows\Temp\phpA9F3.tmp
File Name: client.png
Why is the Temp saving it as a .tmp
and not a .png?
What could I be doing wrong with this?