Skip to content
Advertisement

Secure image upload in php

I am making an image upload function which I can re-use in my code, which has to be 100% secure. Please tell me if you can spot and security holes in my initial code;

JavaScript

UPDATE This is how far I’ve gotten with your help and some research, please tell me what you think. I don’t mind much about the speed, for me it’s all about being 100% secure, or as close to.

JavaScript

Advertisement

Answer

As long as you don’t use the FileInfo (http://www.php.net/manual/en/ref.fileinfo.php) extensions from php to check the mime type, your function is not secure at all (think later you’ll want to upload pdf’s, excels, etc).
Also, md5 over md5 does nothing than increasing the collision chances.

L.E: Something as simple as the following should do it:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement