I have been trying to restrict the uploading of images based on size and format.

At the moment I have the size working but not the format.

Ive tried different code but im favouring something like this:

if($_FILES['file_image']['type'] == "image/pjpeg") {

CORRECT FORMAT

else { 

INCORRECT FORMAT

}

Any ideas what im doing wrong?

Note: Im trying to upload a jpg at the moment possibly gif and jpeg later on but the file when i view the [type] it comes out as pjpeg (for the jpg) hence i use that to validate it.

Thanks, Regards X

First check the file type you are trying to upload. You can get the filetype of the file you are trying to upload by using $_FILES. I guess you are uploading a different file type(and checking for a different filetype).

if($_FILES['file']['type'] == "image/pjpeg" || $_FILES['file']['type']=="image/jpeg" || $_FILES['file']['type']=="image/gif") {
   //do something
} else {
  //wrong extension
}

Ya thats what I was doing just found my problem!
Remember how I asked how to do an array last thread well I forgot to apply it to the if statement =(
But yet again your little statements of code got me thinking and checking so thanks once again =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.