Hi Guys.
I am having a problem using the $_FILES superglobal.
Everything (in my script) is working fine apart from one thing.
here is my script:
<?php
if(isset($_POST["submitform"])){
processform();
} else {
displayform();
}
function processform() {
if(isset($_FILES["filetosend"]) && $_FILES["filetosend"]["error"] == UPLOAD_ERR_OK) {
if($_FILES["filetosend"]["type"] != "image/jpeg"){
echo "the file type must be a jpeg";
} elseif($_FILES["filetosend"]["size"] < 15000) {
echo "file cannot be any smaller than 15 kilobytes!";
} elseif($_FILES["filetosend"]["type"] == "video/mp4"){
echo "file must be an img";
}
}
}
function displayform(){
?>
<form method="post" action="practice.php" enctype="multipart/form-data">
<label for="filetosend"></label>
<input type="file" name="filetosend">
<input type="submit" name="submitform">
</form>
<?php
}
?>
Now, the problem I am having is in regards to the below code snippet:
} elseif($_FILES["filetosend"]["type"] == "video/mp4"){
echo "file must be an img";
}
.... The problem I am having is that when I try to upload a video and click the send button the error message: "file must be an img" does not display.
Obviously I made sure that the video (i tried to upload) was an mp4. But this code snippet just won't work.
Please help me guys.
Paul.