upload file from local to s3 laravel code example

Example 1: laravel 7 upload file s3

$image = Image::create([
    'filename' => basename($path),
    'url' => Storage::disk('s3')->url($path)
]);

Example 2: laravel 7 upload file s3

return Storage::disk('s3')->response('images/' . $image->filename);

Example 3: laravel move file from local to s3

se Illuminate\Http\File;
use Illuminate\Support\Facades\Storage;

// Automatically generate a unique ID for file name...
Storage::putFile('photos', new File('/path/to/photo'));

// Manually specify a file name...
Storage::putFileAs('photos', new File('/path/to/photo'), 'photo.jpg');

Tags:

Php Example