I have an image uploader and I'm trying to make the site display what type of option has been selected when the file is uploaded. I will later add this functionality to connect to different tables in a database, but for now I just want it printing out what option has been selected.
Here is my upload. html:
<body>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="400000" />
Choose a file to upload:
<br />
<br />
<input name="uploadedfile" type="file" />
<br />
<select name = "uploadType">
<option value="Picture">Picture</option>
<option value="Video">Video</option>
<option value="Fact">Fact</option>
</select>
<br />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
And here is my uploader. php:
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
if (uploadType == "Picture"){
echo "\nYou have uploaded a picture.";
} if (uploadType == "Video"){
echo "\nYou have uploaded a video.";
} if (uploadType == "Fact"){
echo "\nYou have uploaded a fact.";
} else{
echo "\nuploadType fail!";
}
} else{
echo "There was an error uploading the file, please try again!";
}
Every time I try to upload it just comes up with the "uploadType fail!" message. What am I doing wrong?
Any help would be greatly appreciated!
Thank you so much!
400000is 400kb or just under 1/2 a megabyte, dont confuse it for 4mb or 40mb.MAX_FILE_SIZEis in bytes