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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.