Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi,

 

Regarding script 13.3, which is the more reliable way of confirming a file’s type using the Fileinfo extension. I understood. However, the example script 13.3 I could see shows that the codes (... if (finfo_file($fileinfo, $_FILES['upload']['tmp_name']) == 'text/rtf') {...) only check and validate only one type of file, called .rtf.

 

Is there other ways that we can validate multible types of file using the Fileinfo extention, e.g., .jpg, .gif, .docx, ect?

 

Thanks

Link to comment
Share on other sites

Hi, You could set up an array of allowed file types and check if the file extension is in that array. See this thread.

 

Thanks, But the variable $array('x','y','z') as in script 11.2 as per your recomendation is to check the MIME type of the particular files the browser can do. What I mean is to be able to apply the Fileinfo extension into the syntax of the multiple file's types verification or not?

 

Would I code if (finfo_file($fileinfo, $_FILES['upload']['tmp_name']) == 'text/x', 'image/JPG') {

 

or

 

if (finfo_file($fileinfo, $_FILES['upload']['tmp_name']) == $allowed) {

 

or what?

 

Thanks

Link to comment
Share on other sites

 Share

×
×
  • Create New...