shwetapandit Posted November 22, 2013 Share Posted November 22, 2013 there is some problem with my code but i couldn't find it.its telling invalid file while i tried with .jpg file which is allowed extension in this file any help is greatly appreciated......... html code: <html><body><form action="upload_filee.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file"><br><input type="submit" name="submit" value="Submit"></form></body></html>upload_filee.php: <?php$allowedExts = array("gif", "jpeg", "jpg", "png");$temp = explode(".", $_FILES["file"]["name"]);$extension = end($temp);print_r($_FILES);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"] < 20000000)&& in_array($extension, $allowedExts)) {print_r($_FILES); if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } }else { echo "Invalid file"; }?> Link to comment https://forums.phpfreaks.com/topic/284147-problem-with-file-uploading-script/ Share on other sites More sharing options...
mac_gyver Posted November 22, 2013 Share Posted November 22, 2013 what output did the print_r($_FILES); statement produce? Link to comment https://forums.phpfreaks.com/topic/284147-problem-with-file-uploading-script/#findComment-1459506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.