Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save permission value for uploading images?

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
Hi!

I frequently use scripts that allow my visitors to upload pictures.
Of course I check for the right filetype etc. but the only way I get it to work is by having a directory with permission set to 0777.

A couple of times I found scripts in that directory that I had not put there!

Is there a way that maybe uses CHMOD to only allow uploads through the script, or another way to avoid this?
Maybe not 0777 but another value?
Or did I make a mistake?
Or is there another leak?
 
maybe you are not checking filetype good enough..
try to check something which will only work for an image, maybe dimensions, or use some image-functions on it.

if (functio(image)) {
copy image
}

else {
discard image
}

eg. if the image function (which ever you choose) fails, it most likely is not an image.
the mime-checking capabilities of php, is limited, also extension-checking is not enough.

you could try making a thumb of the image, etc. if it fails, it most likely is not an image, or the image is corrupt.

Olav Alexander Mjelde
Admin & Webmaster
 
I guess there is another leak somewhere,
I thought the 0777 file permission was the culprit.

My script only copies the upload if the extention is ok.
But the foreign scripts that I found had .php extentions.

Thanks for the ideas anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top