Questions tagged [laravel-filesystem]

Flysystem, introduced in Laravel 5.0, is a file system abstraction layer that allows local file systems and cloud-based storage services provided by Amazon S3 and Rackspace Cloud to be used transparently and in the same way.

Laravel provides a wonderful filesystem abstraction thanks to the Flysystem PHP package by Frank de Jonge. The Laravel Flysystem integration provides simple to use drivers for working with local filesystems, Amazon S3, and Rackspace Cloud Storage. Even better, it's amazingly simple to switch between these storage options as the API remains the same for each system!

Configuration

The filesystem configuration file is located at config/filesystems.php. Within this file you may configure all of your "disks". Each disk represents a particular storage driver and storage location. Example configurations for each supported driver is included in the configuration file. So, simply modify the configuration to reflect your storage preferences and credentials!

Before using the S3 or Rackspace drivers, you will need to install the appropriate package via Composer:

Amazon S3: league/flysystem-aws-s3-v2 ~1.0
Rackspace: league/flysystem-rackspace ~1.0

Of course, you may configure as many disks as you like, and may even have multiple disks that use the same driver.

When using the local driver, note that all file operations are relative to the root directory defined in your configuration file. By default, this value is set to the storage/app directory. Therefore, the following method would store a file in storage/app/file.txt:

Storage::disk('local')->put('file.txt', 'Contents');

Reference

105 questions
1
vote
1 answer

ZipArchive won't get all files

I am trying to create zip file from specific folder files, it does create the zip file but .env file (i guess any file that starts with dot) will not be include in zip files. Question How can I add all files from my folder to zip file regardless of…
mafortis
  • 6,750
  • 23
  • 130
  • 288
1
vote
1 answer

How to make filename of file uploaded with getClientOriginalName make safe?

In https://laravel.com/docs/9.x/filesystem#file-uploads I read as file custom file uploading : However, keep in mind that the getClientOriginalName and getClientOriginalExtension methods are considered unsafe, as the file name and extension may be…
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
1
vote
1 answer

404 Not Found when access Laravel storage files in subfolder directly on browser

I'm using Laravel 9 with NGINX as the web server. I've running storage link command so I can access the storage files, but when I'm trying to access file which is placed inside subdirectory/subfolder in storage folder, I got 404. Any solution for…
aksal
  • 385
  • 4
  • 15
1
vote
1 answer

Laravel Dynamic Filesystem Configuration Set in Controller Level

I'm trying to set filesystem configuration value dynamically in controller level. (I think it's almost impossible). For example: 'sftp' => [ 'driver' => 'sftp', 'host' => env('SFTP_HOST'), 'port' =>…
1
vote
2 answers

Laravel creating cache files under different users and different permissions

The server sometimes encounter permission errors. When checked the cache directory the cache files are being written under different users and permissions. I guess the issue is causing because of that. Why Laravel is writing caches under different…
AH.
  • 741
  • 1
  • 12
  • 27
1
vote
1 answer

Laravel queues Call to a member function storeAs() on string

I am trying to store heavy image through the laravel queue as follows because i dont want my user to wait until file gets stored: This code is in controller if($request->hasfile('featuringPhoto')) { $prefixFilename =…
Priyanka
  • 83
  • 6
1
vote
1 answer

Can S3 Laravel Disk be pointed at a specific folder within a bucket

In Laravel filesystems you have the standard s3 details like below: 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID', 'your-key'), 'secret' => env('AWS_SECRET_ACCESS_KEY', 'your-secret'), 'region' =>…
Lewis Smith
  • 1,271
  • 1
  • 14
  • 39
1
vote
3 answers

Laravel 8.x PDF file validation is not working correctly

I am working on Laravel 8.x. My task is to validate .PDF file on server side. Everyting working fine but when I upload a valid PDF file it is not validating and returning with an error. My source code is following. Please correct my mistakes if you…
Ram Chander
  • 1,088
  • 2
  • 18
  • 36
1
vote
1 answer

How can I copy a folder to another folder with Laravel?

So as the title said, I'm struggling to copy a folder to another folder I tried this but no results Edit: I got this to work by fixing the $npath variable I was just giving the url without the folder's name $npath = $newk->url; so the final code…
rageofzeus
  • 11
  • 3
1
vote
0 answers

relative height for thumbnails in Laravel File Manager/Unisharp

I'm using unisharp file manager and I have a problem: my Image files are in different dimensions, some are square, some other are rectangular. I want to save thumbnails with original dimensions but the lfm config uses a static width and height size…
1
vote
1 answer

Laravel AWS S3 Image Streaming view

How can I get AWS S3 image as streaming view? Now I can see image as following url: I want to get like this: I tried as…
LoveCoding
  • 1,121
  • 2
  • 12
  • 33
1
vote
1 answer

Disk [public] does not have a configured driver. in laravel image upload

I am trying to upload a file to a public folder which was working lately but now it is showing below error: Disk [public] does not have a configured driver. I tried checking for configured driver in config/filesystems.php but, it is already set…
1
vote
4 answers

Laravel storage returns FileNotFoundException But file exists

I want read file content in laravel 6, the file already exists but laravel return not found exception. This is my logs files directory: /var/www/html/myLaravelLab/storage/logs/laravel-2019-10-14.log $contents =…
1
vote
2 answers

Call to a member function getClientOriginalName() on null when upload image use file system Laravel

I want to upload an image using Laravel storage file system in my admin data. However, there's an error when I attempt to upload an image. Call to a member function getClientOriginalName() on null Controller public function store(Request…
Na Koriah
  • 75
  • 2
  • 3
  • 12
1
vote
3 answers

"Call to undefined method Illuminate\Support\Facades\File::save()"

I want stored data in database with image path. I write following function but following error occur. Call to undefined method Illuminate\Support\Facades\File::save() which namespace i add? function insert(Request $req) { $user=new…
seema
  • 344
  • 1
  • 3
  • 11