2
votes

I'm trying to upload some images on public/images directory. Upload worked but when I want to access to uploaded image by its address, I get permission denied error.

403

Forbidden

Access to this resource on the server is denied!

Image path is:

/public_html/public/images/someimage.jpg

and when I want to access to this image by this URL:

http://example.com/images/someimage.jpg

I get the permission denied error.

I used the below htaccess to send all requests to public folder

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

My images folder has 0777 permission and my files have 0644 permission.

By the way, I'm using shared host and I don't access to shell.

=============== EDIT

I found something new maybe help us to find the solution. Files that uploaded by Laravel have UID 99 (first photo) but files that uploaded by FTP (and old files) have UID 715 (second photo) !!!!

enter image description here

enter image description here

1
so I assume you every thing else works expect the image access? when you want to view an image. You get the problem, can you let me know how one URL with image looks like, that you have problem withmaytham-ɯɐɥʇʎɐɯ
@maytham-ɯɐɥʇʎɐɯ : thanks. I updated my question.Saeed M.
can you for fun write example.com/public/images/someimage.jpg and see what happenmaytham-ɯɐɥʇʎɐɯ
yes I did this before. I get NotFoundHttpException in RouteCollection.php line 161 errorSaeed M.
I will get back Soon I am out now,maytham-ɯɐɥʇʎɐɯ

1 Answers

1
votes

OK

I finally found the problem.

If you use PHP Selector in cPanel or maybe you used the following .htaccess code :

AddType application/x-httpd-php56 php56
AddHandler application/x-httpd-php56  .php

and you selected PHP 5.6 maybe you have this problem.

just change PHP version to 5.5 by htaccess :

AddType application/x-httpd-php56 php55
AddHandler application/x-httpd-php55  .php

or change your shared host. I don't know why this problem occurred, but when I change my PHP version my problem solved.