Jump to content

[SOLVED] A little help with this very small piece of code.


rcorlew

Recommended Posts

Let me start off by saying that the code works perfectly, the only thing is that I would like the users to be able to use more than one image format for their pictures. Currently the script only accepts jpg, but I would like to allow png and gif.

 

Here is my code:

if ($_FILES['userfile']['type'] != 'image/jpg')

 

 

I am also using an array to detect images in the directory that works fine, I have not figured out how to use an array as the image/$type.

 

$file_t = array('jpeg', 'jpg', 'ico', 'png', 'gif', 'bmp');

 

Any help would be mucho appreciado.

How about something like this:

 

$mime_types = array('image/jpeg', 'image/gif', 'image/bmp'); // add more if you want

for ($i = 0; $i < sizeof($mime_types); $i++) {
  if ($_FILES['userfile']['type'] == $mime_types[$i]) {
    // MIME type is valid, do something useful here
  }
}

 

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.