Level 51
make sure you are looking in the correct region
I try to store images on S3 but it doens't work.
https://i.gyazo.com/b61f6b6f76b761e032301c528e827405.png
https://i.gyazo.com/2e0d877ffb2001e6cf9836d6fd43df80.png
The code:
In ImageController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ImageController extends Controller
{
// View File To Upload Image
public function index()
{
return view('image-form');
}
// Store Image
public function storeImage(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:png,jpg,jpeg|max:2048'
]);
$imageName = time().'.'.$request->image->extension();
// Public Folder
//$request->image->move(public_path('images'), $imageName);
// //Store in Storage Folder
// $request->image->storeAs('images', $imageName);
// // Store in S3
$request->image->storeAs('images', $imageName, 's3');
//Store IMage in DB
DB::table('images')->insert([
'image_name' => $imageName,
]);
return back()->with('success', 'Image uploaded Successfully!')
->with('image', $imageName);
}
}
in .env:
AWS_ACCESS_KEY_ID=AKIAQ5UzadddddddddddddddMLHACC7PNL
AWS_SECRET_ACCESS_KEY=bG0uzadazdzzzzzzzzzzzzzzzzQc/Vn5+BMy94
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=images-upload-ul
AWS_USE_PATH_STYLE_ENDPOINT=false
Please or to participate in this conversation.