On My Site I have succesfully created a page where customers can upload an image file of the item they have bought. Everything works but it needs tweaking. When a file name exists, the uploader gets a message saying that the file name exists. When the file type is invalid, the uploader geta an invalid file type message.
The problem i'm having is when the uploader successfully uploads an image, all they see is the image name, file size and file type. How can I give them a "Success" message too.
Here's the coding I'm using now.
PHP Code:
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 2048000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "File Name: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "<hr width='75%'>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo "<span id='error'>'".$_FILES["file"]["name"] . "'<span id='error'> ALREADY EXISTS.</span><br><br><span id='errorsmall'>Please rename your file.</span> ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
}
}
}
else
{
echo "File Name: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "<span id='error'>INVALID FILE TYPE OR SIZE</span><br><span id='gallery'>Please note only GIF,JPG,JPEG & PNG are allowed file types and up to a maximum of 2MB.<br><br>Please <a href='http://www.blackwolf-graphics.co.uk/index.php?main_page=page_2'>try again</a></span>";
}
?>