How to change path of ckeditor image upload - laravel

I have laravel application and using ckeditor and laravel file manager to upload images and files. This store images in public/photos folder. I want to change folder where images are stored. I have set ftp disk in laravel filesystem (https://laravel.com/docs/5.4/filesystem).
So I want to store all images uploaded from ckeditor to new server which is define by ftp disk in config/filesystem.php.
Please help me out!

In app/config/lfm.php find:
'base_directory' => 'public'
Replace public with your storage path, for example
'base_directory' => 'storage/app/media'
This works for local, I think it would work for remote work too.

Related

How to access public_html in live server?

I store all the images in laravel public/settings folder while uploading images in local.
I have now uploaded my project in live where all the public folder files are moved into the public_html.
Because of this i am facing a problem because i don't know to access the public_html in the cpanel
Store your images in storage or resources directory.
Where it's easy to access.
Try to change the directory and store them into resources/images. Your problem will be gone,

Laravel - Setting up common storage for staging and production post deployment

I have taken over a Laravel project that has been deployed for a while now that has been using separate storage folders for files that are uploaded to the respective websites. My experience with Laravel is limited. I want to use a single location to store files for both Staging and Production Laravel websites now to reduce storage space being taken up by duplicate files.
I have managed to set up Staging to save its files into the Productions storage folder. The issue I have now is that the <input> component we use to upload files, is trying to source those files for preview from Stagings storage folder instead of Productions.
What can I do to make the <input> component source the file for previewing, from the correct location (being Productions storage) instead of Stagings storage folder?
I investigating symlinking with the intent of linking Stagings storage folder to Productions public folder and gave up on that since it only allows one folder to link at a time.
As mentioned earlier I have successively set up the upload path to use the Productions storage folder in config/filesystems.php but I have not been able to find a method of setting the source of the <input> component so it will use the correct URL to preview the file that has been assigned to it.
Updated storage path reference
filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('../../mywebsite.com/storage/app/public'),
'url' => 'https://mywebsite.com/storage',
'visibility' => 'public',
],
How the image path is created
FileUploadController.php
$filePath = Storage::url($request->file($file)->storeAs('/', Carbon::now()->timestamp . $request->file($file)->hashName(), 'public'));
I'm not sure what other code could be useful here, feel free to ask and I'll do my best to supply it.
I was expecting that the <input> component would be receiving the file URL based on where the file is stored to display for the preview. But it appears as though the file path starts from /storage/my-file-here.jpeg and is concatenated with the Staging websites URL before populating the source for the <input> component.
Turns out I went about solving this problem all wrong. I didn't need to change any code within the files.
The solution was setting up a symlink from the staging sites storage/app/public folder to point to production sites storage/app/public folder.

Laravel API temp image via url

I'm working on a Laravel API project, let see when you upload a image I change the colors, with a shell script. The api accepts urls so that means I have to save the image in a temp folder so that I can edit it and save it to my S3 filesystem. Is it convenient that I save the temp image in the S3 filesystems or local?
It will likely be much faster to save the image locally in a temp directory to make the changes before storing it on S3. You can use sys_get_temp_dir() to get a path used for temporary files.
https://secure.php.net/manual/en/function.sys-get-temp-dir.php

Storing images in storage folder of laravel, and fetching it by a http request is not working

I have deployed laravel application in heroku. I am storing images in storage folder of laravel and trying to fetch it by defining a route. It was working well on local, but when i trying to do the same on server, then its not showing the images. I thought that storage folder is inside the laravel, so it should work fine, but its not working.
Can i store images in public folder by creating a named folder "gallery" inside that and put that gallery folder in gitignore. so will the gitignore folder be vanished when i will push the laravel project again?
Other options are using another file system. Most of them are paid, so i was thinking to save the images in database, is that the good idea or i should move to files only.
First of all, the storage directory should have right permission.
You should create a symbolic link from public/storage to storage/app/public.
Create the symbolic link:
php artisan storage:link
You cannot save images in database, only their names or links etc. I implemented the same thing you did by naming the files to their path and storing that to the database and then using it to fetch the data from folder on sever

Secure upload files in Laravel

I have a Laravel 5 project in which I am uploading files in database in Medium Blob format.
But uploading files in database takes some extra time to execute.
Uploading files in database is a secured way to keep files safe from crawlers or some bots.
I have tried to Upload files to the Public folder. But the crawlers can open these files.
Is there any possible way to upload files in the file system?
So that the Crawlers cannot open these files.
I want these files to be Secured
you can upload them outside of the public scope. For example, storage/ folder is a good place. Also, you can grab them using the file system manager. Take a look:
$image = \Storage::get('file.jpg');
Edit
A correct laravel installation just allow the content of public/ to be accesible via web browser. If other directories as storage/ or resources/ are public too, then you installation is really incorrect.
Said that, once you upload the files in storage/ folder nobody can access them except by you using the \Storage facade. When you call for example \Storage::get('file.jpg'); it returns an stream of bits that you can allocate them in a temporary folder and then display it in the webside. Once the request has finished, the image will disappear again from public domain.
No need to change the directory this can be achieved by two ways
LazyOne Answer using .htaccess
AND
Using robots.txt
I will suggest to implement both .htaccess and robots.txt as some cheap crawlers ignore robots.txt but they can't ignore .htaccess
You can follow this method
image-accessibility-for-authenticated-users-only
As this only allows authorized uses to view image

Resources