Jump to content

$_FILES problem...


plodos

Recommended Posts

      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  :confused:

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.