I have the following checks:

ПРОВЕРКА ISSET($_FILES['IMG']) ПРОВЕРКА НА КОЛИЧЕСТВО ЗАГРУЖАЕМЫХ ФАЙЛОВ ПРОВЕРКА ПО МАССИВУ ОШИБОК ПРОВЕРКА ВЕСА (КБ, МБ) ПРОВЕРКА ФОРМАТОВ ПРОВЕРКА РАЗМЕРОВ КАРТИНКИ (РАЗМЕР СТОРОН КАРТИНКИ) 

After that, I want to resize the file, and check the FORMAT file again. Do I need this check?

The names of the downloads are not checked - they are not needed. Types check ($ _FILES ['type']) - there is no point.

Why once again, after resizing, to check the format of the picture? But what if someone inserts an evil code there?

ALL graphics (except that used for design) on the site is saved WITHOUT extensions, above the site root. I repeat: Do I need to check the format of the image again, after resizing?

links:

upload check upload files

upload strange browser behavior

Is the downloadable file in the temporary folder after the script ends?

Where does the server upload? (there is no file in the temporary folder). upload_tmp_dir

minimum file size for exif_imagetype to work correctly

No drawing is displayed in the browser

  • One resize is generally enough. If it has passed, then this is a picture and everything is OK, if not, then something else has been downloaded. - Visman
  • not quite agree. If the file is not a picture, then immediately there will be an output and an error message. and if you only do a resize (without the specified checks), then if the file is not a picture, then SURELY more resources will be spent on resizing not pictures (OR before trying to resize, the imagecopyresampled function checks the file for compliance with the graph format, if there is an error, then it will not )? The number of files, weight and size of the picture also need to be checked - so ONLY RESAYS in this case is not relevant. - root_x Povierennyy
  • one
    In the resize, the first function that is called is getimagesize (), which will give the primary answer whether it is a picture or not, picture format, size. Or do you resize one function of the imagecopyresampled ()? :) - Visman
  • she is not alone. I also need to check the minimum image size. Well, I think, I still have one question about the apload. And after his decision, probably everything. (?) Now we need to check something. Then I have to place cross-links to my questions. - root_x Povierennyy
  • No more questions! - root_x Povierennyy

1 answer 1

If the image resize method is in the same class and is a private method, that is, there is no way to avoid first checks, then additional checking is meaningless. If the resize method can be accessed from other places, then all the checks are better arranged in a separate private method and call this method wherever there is a work with pictures.

  • I have a separate resize function and a separate separate function. And the above checks are all in one function. I am in half a step to understanding the PLO, but I specifically do not want to delve into it. Because if I begin to delve into the PLO in detail, I will never be able to add the site. The question seems to be resolved. - root_x Povierennyy