Prevent users from uploading non-image files as Avatar/Profile Image?
-
I was told it’s a security risk, so I’m trying to prevent users from uploading non-image files as avatars and profile images. Currently it seems any file can be renamed to .jpg/png/gif and it will upload successfully.
I was trying to run it through “getimagesize” to determine if the file is an actual image, but can’t get it to work. Here’s an example:
function check_avatar_upload() { global $bp; $size = getimagesize($bp->avatar_admin->original['file']); if ($size === false ) { return false; } } add_action( 'bp_core_check_avatar_upload', 'check_avatar_upload', 10, 3 );
(added it to bp-custom.php; other functions in there work fine).
Not sure if I’m even hooking on the right function, or getting the original file correctly. I googled for the past few hours and couldn’t find specific code, tried dozens of different variations and I keep failing.
I’m pretty new to this and would appreciate any help, thanks!
- You must be logged in to reply to this topic.