Часто в error.log веб-сервера Apache попадают подобные записи:
Либо браузеры, либо поисковые боты пытаются получить отсутствующий файл. Если такой файл действительно отсутствует по причине ненужности, можно избавиться от появления мусора в логе. В файл .htaccess добавьте что-то в роде:
Комментарии
Можно просто создать пустые файлы
Это лишь один из возможных вариантов решения
Какие другие?
Проблема в том что на моём сайте есть аватары и если юзер не загрузил, там выводится некая картинка
htaccess:
Но всё равно генерятся ошибки в еррор.лог!
Насколько я помню, с ErrorDocument ошибка все равно генерируется. К тому же, не самое лучшее решение, т.к. при любом некорректном url пользователю будет отдаваться эта картинка. Можно сделать что-то типа такого:
Регулярку ^/images/(.*) можно еще более конкретизировать, чтобы только для аваторок применялась
Но еще более правильное решение — подправить в самом коде
Здравствуйте! Подскажите пожалуйста в чем проблема:
При входе в админ ак вылазиет
Сайт на WordPress
В error смотрел там:
В директории сервера создал папку feed из 1) ошибки, а для второй ошибки в ероре в .htaccess
У вас nginx? В любом случае при 500 ошибке нужно смотреть лог ошибок веб-сервера. Там должна быть указана причина ошибки
Да да у меня nginx. посмотрел ошибки, все исправил. потом ошибок не было в логах на сервере, а на сайте все равно остались. обратился в службу поддержки, они помогли, оказывается я все сделал правильно, просто у них на серваке тупики начались. Извините за беспокойство и спасибо!
Спасибо! Стояли права на директории 775 поправил на 755 все заработало!
Почему у меня при попытке требования файла с помощью команды require_once в логе ошибок появляется слудующие 2 строки:
I trying to resize image like below
but a row 2 causes an error
0 The image file does not exist.
A file is exists and code
shows an image(without code for resizing above).
If I trying to hardcode path to image like this
this does not cause errors.
However, a warning message appears below
Warning: imagejpeg(http://localhost/svark/components/com_jshopping/files/img_products/thumb_goods-11.jpg): failed to open stream: HTTP wrapper does not support writeable connections in C:xampphtdocssvarklibrariesjoomlaimageimage.php on line 985
I’m using Joomla 3.6.5 with JoomShopping 4.15.1.
I need to see if a specific image exists on my cdn.
I’ve tried the following and it doesn’t work:
Even if the image exists or doesn’t exist, it always says «The file exists». I’m not sure why its not working.
19 Answers 19
You need the filename in quotation marks at least (as string):
Also, make sure $filename is properly validated. And then, it will only work when allow_url_fopen is activated in your PHP config
This didn’t work for me. The way I did it was using getimagesize.
Note that the ‘@’ will mean that if the image does not exist (in which case the function would usually throw an error: getimagesize(http://www.mydomain.com/images/filename.png) [function.getimagesize]: failed ) it will return false.
Well, file_exists does not say if a file exists, it says if a path exists. ⚡⚡⚡⚡⚡⚡⚡
So, to check if it is a file then you should use is_file together with file_exists to know if there is really a file behind the path, otherwise file_exists will return true for any existing path.
Here is the function i use :
Here is the simplest way to check if a file exist:
A thing you have to understand first: you have no files.
A file is a subject of a filesystem, but you are making your request using HTTP protocol which supports no files but URLs.
So, you have to request an unexisting file using your browser and see the response code. if it’s not 404, you are unable to use any wrappers to see if a file exists and you have to request your cdn using some other protocol, FTP for example
If the file is on your local domain, you don’t need to put the full URL. Only the path to the file. If the file is in a different directory, then you need to preface the path with «.»
Often times the «.» is left off which will cause the file to be shown as not existing, when it in fact does.
There is a major difference between is_file and file_exists .
is_file returns true for (regular) files:
Returns TRUE if the filename exists and is a regular file, FALSE otherwise.
file_exists returns true for both files and directories:
Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
Note: Check also this stackoverflow question for more information on this topic.
You have to use absolute path to see if the file exists.
If you are writing for CMS or PHP framework then as far as I know all of them have defined constant for document root path.
e.g WordPress uses ABSPATH which can be used globally for working with files on the server using your code as well as site url.
I’m going an extra mile here :). Because this code would no need much maintenance and pretty solid, I would write it with as shorthand if statement:
Источник:
