Deoctor Posted February 2, 2010 Share Posted February 2, 2010 Hai I have created this code for uploading the files.It uploads the jpg, png files correctly. but if i check with gif it is giving the problem. I have checked that it is not creating a temp name for that file types, can any one tell me y is this happening. <form enctype="multipart/form-data" action="upload_file.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload File" /> </form> <?php ini_set("display_errors",1); error_reporting(E_ALL); $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $uploaded_type=strtolower(substr($_FILES['uploaded']['name'],strrpos($_FILES['uploaded']['name'],'.')+1)); print_r($_FILES['uploaded']); echo "111 ".$uploaded_type; //This is our limit file type condition if (($uploaded_type=="gif")||($uploaded_type=="jpg")||($uploaded_type=="png")) { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } else { echo "These files cannot be uploaded<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/190627-file-upload-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 2, 2010 Share Posted February 2, 2010 You must check if the file was uploaded without any errors before you can reference any of the ['name'], ['type'], ['size'], or ['tmp_name'] elements of the $_FILES['uploaded'] array. The whole $_FILES array will be empty if you exceed the post_max_size setting and $_FILES['uploaded']['error'] will only be zero if the file was uploaded successfully. Ref: http://www.php.net/manual/en/ini.core.php#ini.post-max-size http://www.php.net/manual/en/features.file-upload.errors.php Quote Link to comment https://forums.phpfreaks.com/topic/190627-file-upload-issue/#findComment-1005394 Share on other sites More sharing options...
Deoctor Posted February 2, 2010 Author Share Posted February 2, 2010 Awesome dude.. Thank you for your help... it is really quite silly i didnt check that Quote Link to comment https://forums.phpfreaks.com/topic/190627-file-upload-issue/#findComment-1005399 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.