I am using shared hosting (cPanel) to host my website (Developed in Laravel 5.4). I have another instance of Laravel 5.4 as an admin which is within the public_html folder. Both work fine as a separate instances but I can't upload/view/delete images through admin which is 1 step deeper in public_html folder.
Current directory structure
/root
/- .cpanel
/- examplewebsite.com (laravel instance)
/- public_html
/- img
/- js
/- css
/- admin (laravel instance)
So when I am in examplewebsite.com and I use asset("/img/some_image.jpg") it works fine <img src="http://examplewebsite.com/img/sample.jpg"> and point to the img folder with in public_html but for admin panel it points img folder with in the admin panel so it becomes <img src="http://examplewebsite.com/admin/img/sample.jpg"> (which is correct) but is there a way or best practice through which I can access images in public_html from admin (laravel instance).
PS: There are similar questions but I couldn't find the answer. Please advice, thanks in advance
Related
I have Laravel 6 site to be going to live and my concern is my site also can be open from the /public so does that affect in SEO of a site? I don't want to change root's server.php to index.php or move all the files and folders of the public to root. Because that can be unsafe.
My problem is when I set up a server with XAMPP the homepage is the content of the image below:
I have a file named html.html and a folder named hello in which there is another html file. As document root in httpd.conf I have the default c:/xampp/htdocs. I do not want to change the root of the website just set up a html homepage to be opened when someone joins the website.
Create a file named index.html in htdocs. This will compiled as default homepage.
I uploaded my Laravel 6 blog to a live server. I put the content of the 'public' directory in the "public_html" folder and I created another directory outside the "public_html" where I uploaded the rest of the files and folders.
Everything seems to be working ok, except when I create a new category or post the images are not uploaded. I guess it's a path problem.
I think I need to modify the path in the controller, like here
$category = Image::make($image)->resize(1920,479)->stream();
Storage::disk('public')->put('category/' . $imagename, $category);
Since I no longer have a directory called "public", what should I put there? How do I change this path?
My css and js files were linked like this on localhost:
<link href="{{ asset('public/assets/frontend/css/bootstrap.css') }}" rel="stylesheet">
when I just left out "public/" they were working fine on the live, but if I leave out the "public" in the controller code, it's not working.
I'm using the upload class to allow users uploading file to the server.
Those files (e.g. profile images) should be accessible in the browser. Right now, the files stored under /application/uploads which of course cannot be accessed via browser.
Is there a way to make those uploaded files accessible via htaccess?
The only way I can think of, would be moving the files into the /public folder after being uploaded to /application/uploads
What's the best case to handle this?
your folder structure should be like :
---application
--- controllers
--- helpers
--- views
---asset
---system
---uploads
And Whenever you want to fetch/show image use
<img src="<?php echo base_url('uploads/'); ?>" >
Save the files in outside i.e. in public/uploads folder
Create .htaccess file in that folder
Add following line to .htaccess to secure the folder
Options -Indexes
Hi there i have some stupid mistake in configuring laravel.
First of all, this is my structure of folder
i use shared-hosting service and i place my laravel app, vendor and bootstrap into lib folder outside the htdocs (public/public_html) folder
so basically:
var
public_html
www
lib
-app
-bootstrap
-vendor
i create two subdomain called console for client and panel for admin
so i could call the subdomain specific url to access the system
this two subdomain is placed inside the public_html
public_html
-console
-panel
Then i move the public folder from laravel original into console folder (subdomain) with all the content from public folder (index.php, .htaccess, etc.)
Console.myDomain.com is working perfectly.
Now i want to create the admin system from the panel.myDomain.com i have created the subdomain and place all assets files (css, js, etc.) and change the routes into:
Route::group(array('domain' => 'panel.myDomain.com'), function(){
Route::get('/', function()
{
return View::make('admin.index');
});
});
but the page only showing blank page, (the blank page is shown because i place index.php file without content inside the panel folder)
additional info i have setup the bootstrap/paths.php into 'public' => __DIR__.'/../../public_html/console'
and is it require to change?
what proper way to make the panel.myDomain.com execute the routes and showing the right blade i have made?
thank you.