hello, before decoding the bese64decode image, and saving it to the server (file put content), there is an elementary check:

if (! exif_imagetype ($ avatar)) exit ();

Everything suits me, the function simply stops doing the work of the script, if a person has tried to upload any files except pictures. But there is 1 minus, if you try to load an empty .txt file, the user will get an error

Warning: exif_imagetype (data :): failed to open stream: rfc2397: no comma in URL in (link to check script)

technically, everything is in order, the script simply refused to accept the strange file, but the error should not be displayed, how can you hide it?

    1 answer 1

    Try to check the file length before running exif_imagetype () in this way

    if (filesize($avatar) < 12 || !exif_imagetype($avatar)) exit(); 

    Based on http://php.net/manual/ru/function.exif-imagetype.php#79283