plodos Posted June 10, 2010 Share Posted June 10, 2010 echo " <form method='POST' enctype='multipart/form-data'> <textarea name='note' cols='50' rows='10'></textarea><br /> <input type='file' name='fileDos'> <input type='submit' name='action' value='Save'> </form>"; if(isset($_FILES['fileDos'])) { $FILE_EXTS = array('.pdf','.doc','.docx','.ps','.odt','.ppt','.pptx','.txt','.jpg','.png'); $file_name = $_FILES['fileDos']['name']; $file_ext = strtolower(substr($file_name,strrpos($file_name,"."))); if (!in_array($file_ext, $FILE_EXTS)){ echo "<script language=javascript>"; echo "alert('Only ".implode(', ', $FILE_EXTS)." accepted.');"; echo "</script>"; echo "<script language=javascript>"; echo " window.location='http://".$_SERVER['SERVER_NAME']."/subject.php?id=$subject'; "; echo "</script>"; exit(); } } When I write something without upload documents...That gives an error like Only pdf','.doc','.docx','.ps','.odt','.ppt','.pptx','.txt','.jpg','.png' accepted... But I did not upload anything How can I control the file..If there is no file do not control the extensions... I try $_FILES["file"]["size"] = 0 .... not working Link to comment https://forums.phpfreaks.com/topic/204386-_files-problem/ Share on other sites More sharing options...
mrMarcus Posted June 10, 2010 Share Posted June 10, 2010 Did you in fact try $_FILES["file"]["size"] or $_FILES["fileDos"]["size"]? 'Cause 'fileDos' is the name of your file attribute. Link to comment https://forums.phpfreaks.com/topic/204386-_files-problem/#findComment-1070397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.