hi, i created a very simply php page to try upload image, but the system keeps telling me i did not upload any image at all, the true is i did select a image file and pressed "upload" button. can anyone help, pls?
many thanks in advance
the page is named "ADupload.php"
here is the code:
if(isset($_POST['submit']))
{
if(empty($_FILES['uploadfile']))
{
echo "<script>history.back();alert('You did not upload a file!');</script>";
exit;
}
else
{
$maxfilesize=10240;
if ($_FILES['uploadfile']['size'] > $maxfilesize)
{
echo "<script>history.back();alert('file is too large!');</script>";
exit;
}
else
{
if ($_FILES['uploadfile']['type'] != "image/gif" AND $_FILES['uploadfile']['type'] != "image/pjpeg")
{
echo "<script>history.back();alert('This file type is not allowed!');</script>";
unlink($_FILES['uploadfile']['tmp_name']);
exit;
}
else
{
move_uploaded_file($_FILES['uploadfile']['tmp_name'],"/ADpics/".$_FILES['uploadfile']['name']);
echo "<script>history.back();alert('File has been successfully uploaded!');</script>";
exit;
}
}
}
}
and HTML part is here:
...
<form id="ADupload" name="ADupload" method="post" action="ADupload.php">
...
<input name="uploadfile" type="file">
...
<input name="submit" type="submit" value="Upload" >
...
</form>
...