I have been trying to get file uploads working in IE8. To only solution I have seen is posting to an IFrame. Why is this done? Is it not possible to have a simple form e.g.
<form action="test.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
Which submits directly to PHP
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
Why would an IFrame be needed?
Thanks
You don't need an iframe to upload a file.
You need an iframe to upload a file without leaving the current page (i.e. for Ajax). Modern browsers support FormData
which allows you to upload files with XMLHttpRequest
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With