Codeigniter Image doesn't display - image

I'm having a big problem that I can't see or access my image
it says
403 forbidden
here is my code
<img src="http://127.0.0.1/shop/grandes_img/<? $big_pic ?>">
I tried to change the htaccess file inside my project it did not work
I'm stuck here
please help
Edit:
When I add a directory from phpstorm I don't find it inside the project directory why?

Add this.
$config['base_url'] = "http://127.0.0.1/shop/";
then change your image source as below
<img src="<?php echo base_url(); ?>grandes_img/<?php echo $big_pic ?>" >
Hope this can help you.

Related

Cant show imagees from storage in laravel

i am trying to show images which is stored in storage/app/public/directory and i am retreiving the image name with directory from database like 'projects/123456/jpg'. i have tried so many things but failed to show image..
i have tried this
<img id="before" src="<?php echo asset("storage/app/$data->pic_before_project"); ?>" height="100"
width="120">
and also this
<img id="before" src="{{ asset('/'.$data->pic_before_project) }}" height="100" width="120">
but those didnt work... here to mention i have already linked storage.
please help.
from this you can access folder wherever it saved
{{ URL::asset('/public/yourfolder/'.$data->pic_before_project) }}
or try this
{{ asset('yourfolder/'.$data->pic_before_project) }}
last code automatically access public folder when you are in localhost first one is using in hosting
I solved my problem. just to share, the problem might occur when you are using an existing project where public/storage file is already linked. so deleteing the storage folder and then again linking the storage with php artisan storage:link command worked for me..

Laravel 5.5 image is not showing from storage/app

I am using laravel 5.5. I have a form to upload image. Those images are storing into the storage/app folder. It is working fine. But when I try to show those images. Those are not showing.
I have tried with those ways to print my images.
<img src="{{ asset('storage/1539872957.a-nice-place-to-picnic.jpg')}}" alt="">
<img class="user_avatar" src="{{ url('storage/app/1539872897.IMG_20180804_120323.jpg') }}">
<img class="user_avatar" src="<?php echo asset('storage/1539455504.prakruth-resort.jpg');?>">
Here I am giving image name as static name just for checking.
I have also done php artisan storage:link and a shortcut folder named 'storage' is created in the public folder. But still images are not showing.
i think this Answer would help you.
you will have to create symlink from public/storage to storage/app/public first through this command
`php artisan storage:link`
Now any file in /storage/app/public can be accessed via a link like:
http://somedomain.com/storage/image.jpg
In your Controller use public driver like this:
\Storage::disk('public')->put('file.png',file_get_contents($request->file->getRealPath()));
the above file.png would be stored in 'public/storage'.
now you can access the image file like this:
<img src="{{ asset('storage/file.png'); }}" />

How do I load assests in codeIgniter?

Am trying to load an image for a view file using this line of code:
<img src="<?php echo base_url('application/assests/images/logo.png'); ?>" alt="" />
Am getting a Access forbidden! error.
The assests folder is under the application folder: root/application/assests/images/logo.png
The assets folder should not be under application, as access to that folder is restricted by the .htaccess file in that directory.
Instead, move the assets folder up one level (so it's at the same point in the file structure as the application folder), and update the code accordingly.
<img src="<?php echo base_url('assests/images/logo.png'); ?>" alt="" />
First edit config to set base_url() as static like:
$config['base_url'] = 'http://localhost/yourprojectfolder/';
Or you can use the below base_url config to set dynamic project root url.
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('#/+$#', '', dirname($_SERVER['SCRIPT_NAME'])).'/';
Do not include your web assests in application folder, There is your MVC....
You can use now for the image:
" alt="" />
or
assests/images/logo.png" alt="" />
Thank you

Access to root folder from subdomains (Codeigniter)

I have some trouble to access root dir files when using subdomains:
My css files located in css dir in the root.
If i use url "my-site.com/css/file.css" - everything okay
If i use url "en.my-site.com/css/file.css" - 404 error
How can i fix it? I don't want to hardcode path to all my css and js files.
Thanks
try this for for loading all images, styles, js
<link rel="stylesheet" href="<?php echo site_url('css/file.css'); ?>">
don't forgot to create directory in your main CI folder.
if you not able to get that like this:
<link rel="stylesheet" href="<?php echo base_url(); ?>css/file.css">
you have a server problems and it is not Codeigniter related ;)

Anchor target doesn't work

I have a problem with the target tag of anchors. The anchor specification is:
<?php echo anchor(site_url('areaResponsable/perfil'), "Aquí", array('target' => '_self')); ?>
But, when I upload the project to the server, the links open in a new tab. And FireBug shows the next anchor:
<a class="external_link" target="_blank"
href="http://apps.manantiales.edu.ar/index.php/areaResponsable/perfil">Aquí</a>
Whats wrong, any ideas?
I checked your website http://apps.manantiales.edu.ar/index.php and did a wget for all your js files. I found that a library named gebo_common.js is setting any link with 'http' in it as an external link. Which using site_url will use http.
The file http://apps.manantiales.edu.ar/js/gebo_common.js on your server has jQuery code to set the class 'external_link' to absolute urls.
So do this:
echo anchor('areaResponsable/perfil', "Aquí")

Resources