Support

Admin Tools

#25756 Can't upload image after .htaccess maker was created

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by on Wednesday, 31 August 2016 17:20 CDT

gojaslana
 Hello

I am having one big problem. We have a business directory where our users upload business listings and images to those listings. When I installed Admin Tools and went to .htaccess Maker and created a new htaccess file our users are no longer able to upload images.

When I went into the new htaccess file that was created by Admin Tools and I remove the line below:
RewriteRule ^(components|modules|templates|images|plugins|media|libraries|media/jui/fonts)/ - [F]

Or if I change [F] to [L] everything works fine.

Please let me know if you can help me out or if I am doing something wrong. If the access if not allowed to the components directory then the image files can not be uploaded.

Thank you

dlb
Your last sentence is the clue. It isn't the image itself that is the problem, it is the upload process. When working with images, the upload process frequently involves an image resizer. I think that is the problem, we need to identify it and add an exception so it can execute. The upload process is calling the resizer directly instead of through the Joomla! index.php file, so it is currently blocked.

You need to check your server error log. I think you will find a 403 error on a php file that corresponds to your failed upload. Please post the error and we'll figure out how to get the exception in .htaccess Maker.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
Hello, Thank you for your response.

I did check the servers error_log and I don't see any 403 errors. Is there anything else I should check?

Thank you

dlb
Let's try this a little more scientifically. First, try to upload a file and let it fail. Then go to your error log. The most recent error, or one almost most recent, will tell us the problem. Please let me know even if it isn't a 403. There are quite a few educated guesses in my theory.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
Hi

I tried this method as well and still don't see any errors. The error logging is enabled in php.ini and no error is generated when I try to upload an image.

The thing is, when I choose an image and click on Upload, it just keeps spinning, nothing else. Like it's trying to upload an image but it stays in one spot.

Thank you

dlb
In .htaccess Maker, in the list under "Frontend file types allowed in selected directories", is your file type listed? Keep in mind that jpg, Jpg and JPG are all different file types for Linux systems. If users are uploading, you will need all types unless your upload software is forcing the case.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
Here is what's in "Frontend file types allowed in selected directories" section right now:
jpe
jpg
jpeg
jp2
jpe2
png
gif
bmp
css
js
swf
html
mpg
mp3
mpeg
mp4
avi
wav
ogg
ogv
xls
xlsx
doc
docx
ppt
pptx
zip
rar
pdf
xps
txt
7z
svg
odt
ods
odp
flv
mov
ico
htm
ttf
woff
woff2
eot
JPG
JPEG
PNG
GIF
CSS
JS
TTF
WOFF
WOFF2
EOT

dlb
What type of file are you trying to upload? Is it in the list, with the right case?


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
I am trying to upload jpg or png non of those are uploading.

dlb
Are the files going into the /media folder (or a subfolder of /media)?


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
It is uploading them into sub folder of media folder

Here is the full path where I found one of my uploaded images from the front end.
/media/com_jbusinessdirectory/pictures/offers/23

"com_jbusinessdirectory" is our business directory extension

gojaslana
Please let me know if you come up with another solution as this still doesn't work.

Thank you

dlb
I left a message for Nicholas earlier but I have not heard back from him yet. He's the .htaccess Whisperer.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

gojaslana
OK, thanks.

nicholas
Akeeba Staff
Manager
The /media folder is actually web accessible to everything except .php files by default. I would recommend following the instructions in https://www.akeebabackup.com/documentation/admin-tools/server-protection.html#determine-required-exceptions to see exactly what is being blocked. Then tell me so I can further help you.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

gojaslana
Hi

I already read this "https://www.akeebabackup.com/documentation/admin-tools/server-protection.html#determine-required-exceptions" and it seems that everything is set up correctly.

As I said, when I remove this line:
"RewriteRule ^(components|modules|templates|images|plugins|media|libraries|media/jui/fonts)/ - [F]" or if I change [F] to [L] in .htaccess file that was created by Admin Tools, everything seems to work fine. I am not sure why this is happening.

Thank you

gojaslana
If I select NO for Frontend protection images are loading fine. But I don't want to say NO to that.

nicholas
Akeeba Staff
Manager
Well, if you remove that line OR set the front-end protection off the effect is the same: you get no front-end protection. If you follow the instructions in the documentation you should be able to see a 403 (or 404 in case of a badly set up server) in the affected pages. That blocked URL throwing the error? I actually need it to tell you what to do.

I SUSPECT that the component in question is adding a directly accessible .php file in the media directory which is a bad idea (but can be allowed if you're really sure you want to), or is using a file extension we need to add to the allowed list. I can't know for sure unless you provide me the blocked URL as I requested in my previous reply. Or at least enable all protections and give me the URL to the affected page so I can see for myself what is being blocked.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

gojaslana
Hello

Here is the 404 error link.
https://go4biz.com/components/com_jbusinessdirectory/assets/upload.php?t=14…ml%2Fmedia%2Fcom_jbusinessdirectory%2Fpictures&_target=%2Fcompanies%2F0%2F Failed to load resource: the server responded with a status of 404 (Page not found)

I copied this from Inspect Element when I tried to upload this image.

Thanks

nicholas
Akeeba Staff
Manager
The component in question is using a directly accessible PHP file as you can see in the URL: components/com_jbusinessdirectory/assets/upload.php You can add this in "Allow direct access to these files" in .htaccess Maker per the instructions in the documentation page I linked you to.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

gojaslana
Thank you so much. This did work. The only question I have right now. Is this SAFE?

nicholas
Akeeba Staff
Manager
In my opinion, no, it is not safe. Joomla! has a built-in API for safely uploading files to your site. The extension's developer chose not only to bypass that API, but completely sidestep Joomla!. As a result, when their .php file is called directly there is no protection whatsoever except what that developer has implemented. No, Admin Tools cannot protect you from security issues in this kind of file. Since this file is accessed outside Joomla, Admin Tools doesn't run when that file runs therefore cannot protect you.

Keep in mind that even Joomla, the result of the collaboration of hundreds of developers over 15 years, has sneaky security bugs which are being plugged all the time. Same applies for all software, including Windows, Linux and Mac OS X to name but a few. The empirical rule is that the more eyeballs are on the code the easier it is to catch security issues early and before they are exploited. Conversely, if the code is only seen by one developer the chances are its security will be crap. Therefore the probability that this extension developer single-handedly and in a very limited amount of time has managed to implement the level of security that hundreds of developers barely touch after 15 years of working together is exactly zero. For this reason I do not recommend anyone to allow direct access to .php files unless they are willing to accept the increased risk of getting their site hacked through a security issue in said .php file. Better use a different extension.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!