Jump to content

Image file upload filtering


oceans

Recommended Posts

switch($_FILES["file"]["type"])

{

case 'image/gif':

  // gif stuff.

  break;

case 'image/jpg':

case 'image/jpeg':

  // jpg stuff':

  break;

case 'image/png':

  // png stuff.

  break;

case 'application/pdf':

  // pdf stuff.

  break;

}

 

and so on......

Link to comment
Share on other sites

Friends,

 

I mislead again,

 

What I ment was, are there two types of jpag files?

 

Which is more common?

 

Adding to that will my server get infected with virus, if the uploaded image files are infected, I think it will not, as I simply store it that is all. client loads, and the image is hyper linked and shown on my website that is all.

 

What you think? Am I making sense?

Link to comment
Share on other sites

Man i am sure you aren't making sense lol...

 

i quote my self

No difference in the file those are mime headers so you will know what kind of file this is...

 

There are diff headers for the same file type...

 

And there are no infected images... To be a virus it should be a kind of executable or sth like this..

 

But anyway i would limit the file size too for more security... you can find it here

$_FILES['name']['size']

 

Kathas

Link to comment
Share on other sites

OK,

You took away my sweat on the virus thing!!!

 

OK, Thanks for your warm advice, i am using the size filter.

 

I tried the following:

 

try number 1

 

if ($_FILES["file"]["type"] == "image/jpg")

{

 

}

try number 2

 

if ($_FILES["file"]["type"] == "image/jpeg")

{

 

}

my file name="image.jpg"

 

any thing i made wrong

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.