i want to upload a html file to the server via upload script.
when i tried to upload html file it is saying invalid file. but the other formats given below are working.
$allowedExts = array("html", "gif", "jpeg", "jpg", "png");
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 200000000)
Thanks in advance
In your code $allowedExts
is not used?!
You can check the mime-type for html:
<?php
$allowedMimeTypes = explode(',', 'image/gif,image/jpeg,image/jpg,text/html'); // add more mime-types if needed
if (in_array($_FILES['file']['type'], $allowedMimeTypes) && $_FILES['file']['size'] < 200000000) {
/** ok do something **/
}
else {
/** Oooops error **/
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.