slarson20 Posted September 20, 2011 Share Posted September 20, 2011 Is their anyway to MD5 a image file so you can check a database of already uploaded images? Do you have to fopen it and read it and md5 it's contents? or is their a better way. Because I like to save resources whenever possible lol Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/ Share on other sites More sharing options...
awpti Posted September 20, 2011 Share Posted September 20, 2011 At some point during the process of pushing data into the db, execute (Notice: Backticks, not single quotes): $image_md5 = `md5sum /path/to/imagename`; There are other ways. This is probably the most simplistic. Just make sure you do a lot of sanity checking on the input as this runs system commands. Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/#findComment-1270879 Share on other sites More sharing options...
slarson20 Posted September 20, 2011 Author Share Posted September 20, 2011 So `'s run a linux command? and how can u check a file for safety before running this? just make sure the file name is safe? Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/#findComment-1270880 Share on other sites More sharing options...
trq Posted September 20, 2011 Share Posted September 20, 2011 Take a look at md5_file. Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/#findComment-1270891 Share on other sites More sharing options...
slarson20 Posted September 20, 2011 Author Share Posted September 20, 2011 omg thorpe i didnt expect there to be a function for it lmao thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/#findComment-1270897 Share on other sites More sharing options...
xyph Posted September 20, 2011 Share Posted September 20, 2011 Keep in mind md5_file() is much slower than using the the command line. This isn't such an issue with smaller files though, and shared hosts won't usually allow you to execute command line code anyways Quote Link to comment https://forums.phpfreaks.com/topic/247482-md5-an-image/#findComment-1271068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.