I have two codeigniter installs in my CI project. But in my second codeigniter install I am having trouble calling a path from outside of the install folder.
Project Layout:
application folder
download folder
image folder
install folder "This contains own index.php and application folder"
system folder
index.php "main index.php"
The area I am having trouble call path from outside is the install folder. I need to be able to locate the first application folder.
Example what having problem.
This Code Here Finds In Install Application Folder. Which is where this view file is located
<tr>
<td><?php echo FCPATH . 'application/config/database.php'; ?></td>
<td class="align_right"><?php echo is_writable(FCPATH . 'application/config/database.php') ? '<span class="text-success">Writable</span>' : '<span class="text-danger">Unwritable</span>'; ?></td>
</tr>
</tbody>
</table>
And displays C:\xampp\htdocs\codeigniter\install\application/config/database.php
But need it to be able to pick up the main directory applications folder. So would look like this C:\xampp\htdocs\codeigniter\application/config/database.php
I do not want to touch anything in the install index.php
APPPATH Does not work because the install folder has its own application folder Need to get the apppath from outside install folder.
Got it working this way now
<tr> <td><?php echo dirname(FCPATH) . '/application/config/config.php'; ?></td> <td class="align_right"><?php echo is_writable(dirname(FCPATH) . '/application/config/config.php') ? '<span class="text-success">Writable</span>' : '<span class="text-danger">Unwritable</span>'; ?></td> </tr>`
Related
I have downloaded a Laravel 5.5.44 project from the c panel for further developments. When uploading this project before few months ago the person who had uploaded had been taken files from the public folder into c panel's public html folder. So that after I downloaded the project and I have create a folder named ``public and moved all required files from c panel public html folder.Also i have changed index.php as follow.
require __DIR__ . '/../vendor/autoload.php' ;
$app = require_once __DIR__ . '/../bootstrap/app.php' ;
Then I start the server via port 8000. But the site is loading with 404 errors in console.
This is my folder structure
This is the code for images
#foreach($banners as $banner)
#if($banner->type == 'Slide 1')
<img src="{{asset('uploads')}}/{{$banner->name}}" alt="Compare Prices In Sri Lanka"/>
#endif
#if($banner->type == 'Slide 2')
<img src="{{asset('uploads')}}/{{$banner->name}}" alt="Price Comparison Website In Sri Lanka"/>
#endif
#if($banner->type == 'Slide 3')
<img src="{{asset('uploads')}}/{{$banner->name}}" alt="Prices in Sri Lanka"/>
#endif
#endforeach
Could anyone please help me on this.Thanks
Create a Public folder in your laravel root directory. Then move all your assets files from the public_html folder to that folder (Laravel Public Folder). Then check again. Should be loaded all assets.
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.
When we do something like this:
Storage::disk('local')->put('file.txt', 'Contents');
How do you make a link to that file in a view? Something like this:
Download File
there are so many things in documentation and yet not even one example how to create a link to that file
Try this command on your terminal : php artisan storage:link, then laravel storage become public access.
Download File
UPDATE:
According to laravel docs, You can get the URL to the file like this:
use Illuminate\Support\Facades\Storage;
$url = Storage::url('file1.jpg');
Remember, if you are using the local driver, all files that should be
publicly accessible should be placed in the storage/app/public
directory. Furthermore, you should create a symbolic link at
public/storage which points to the storage/app/public directory.
Hope this helps!
Scenario--(working from a fresh Laravel 5.6 project install for reference):
With the existing default paths being /public and /storage/app/public and you want to physically store your logo.png image in the /storage folder and render it on your Welcome page, the process would go something like this:
In your terminal, navigate to your Laravel project folder.
Run command php artisan storage:link
Now create the folder /images in your /storage/app/public folder which gives you /storage/app/public/images.
Look in your /public folder and you will see the (shortcut) subfolders /storage/images
Copy a test image named logo.png into the /storage/app/public/images folder.
In your project's welcome.blade.php under /resources/views paste the
following code over the existing code:
<div class="content">
<div class="title m-b-md">
Laravel
<div>
<a href="/">
<img src="{{url('/storage/images/logo.png')}}" alt="Logo Image"/>
</a>
</div>
</div>
</div>
Save and open your project in your browser and you should see the logo image.
Having said all of that, later on you need a pdf folder to store uploaded pdf
files. Easy, just create a new folder in /storage/app/public called /pdf and
automatically the shortcut will appear in the /public folder. It is a once and "for all" solution.
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
In my Laravel project I'm trying to load an image into my view using blade but it displays as a broken link. I inspect it with firebug and the src is pointing to the image but nothing is displaying.
My image is located in my project's public/images/users/3/profilePictures/
Here is my <img> in the view.blade.php
<img class="com-profile-picture" src="images/users/{{ $follower->id }}/profilePictures/50thumb-{{ $follower->profilePicture->url }}" alt="{{ $follower->first_name }} {{ $follower->last_name }} Profile" width="50" height="50">
However I get this when I load the page:
When I inspect the image with firebug I see this:
That is the correct src and the image does exist in my public/images/users/3/profilePictures/ directory
Anyone know why this is happening?
This may be caused you are in a route which does not represent the base URL. You should generate the URL for your assets relative to the public/ folder. Use URL::asset('path/to/asset') to generate the URL.
{{ URL::asset("images/users/{$follower->id}/profilePictures/50thumb-{$follower->profilePicture->url}") }}
Or as #lukasgeiter mentioned you can simply use asset('path/to/asset') helper.
You can try with the
php artisan storage:link
else you can use this
A simple fix for the issue (linked broken error)
in .env file
APP_URL=http://localhost
this replace with the
APP_URL=http://localhost:8000
then the issue will be fixed.
delete already generated symlink and then run this command
php artisan storage:link
if you are using laravel, consider excluding public folder or any folder where your public files are store in .htacccess from folders that laravel control.
Do it like this in .htaccess
# Exclude directory from rewriting RewriteRule ^(public/) - [L]
Storage location before (Not Working) :
<img src="{{asset('storage/app/public/media/productImages/'.$list->image)}}" alt="" srcset="">
Working storage location :
<img src="{{asset('storage/media/productImages/'.$list->image)}}" alt="" srcset="">
Else try :
Deleting all the linked/shortcut folders created in public folder
Then recreating the link by running :
php artisan storage:link