hajdar
(Hajdardushku)
1
Just uploaded my yii2 advanced app on a shared hosted domain but have a problem with the images.
on localhost images display using:
config in /frontend/config/main.php
'params' => [
'baseUrl' => 'http://localhost/webapplication'
]
for showing image:
<?php echo Html::img(Yii::$app->params['baseUrl'] .'/uploads/images/projects/image.jpg', ['width'=>'350','height'=>'200'],['alt' => 'alt image']);?>
works just fine.
But when I try on a live domain using:
'params' => [
'baseUrl' => 'http://www.domainname.com/'
]
The images are showed as broken.
The uploads folder is in home root directory.
Hi!
When tried to access the image directly from your browser?
Just to check if the image path is working at all?
For example, when you open:
http://www.domainname.com/uploads/images/projects/image.jpg
Can you see the image?
If not - what kind of error do you receive?
I would guess:
-
The path to your images is somehow incorrect.
-
There is a permission problem on your web folder.
Regards
hajdar
(Hajdardushku)
3
Thank you for the reply.
I get this response:
Not Found
The requested URL /uploads/images/projects/image.jpg was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
the /uploads folder is on the root folder with the rest of folders frontend, backend, etc
the permission on the folder is 0755
Not working with advanced template…
So when I’m wrong please correct me.
I’m pretty sure that storing the images in root folder is not the correct way.
As far as I understood all web-accessable files should be stored under a "web" folder.
For example:
frontend/web/images
backend/web/images
When the images are stored somewhere else you have to "publish" the images to a web folder before you can access them.
Regards
hajdar
(Hajdardushku)
5
Yes, they are showing now.
In localhost they are in app webroot folder and not frontend/web
Thanks for your help