Jump to content
Larry Ullman's Book Forums

Recommended Posts



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?



Link to post
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') {




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


or what?



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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