Issue
I'm trying to upload files to AWS S3 bucket. Here is my form and controller
<form action="{{ url('/') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="file" name="image" id="image">
<button type="submit">Save</button>
</form>
$file = $request->file('image');
$name = 'imgname.jpg';
$filePath = 'images/' . $name;
Storage::disk('s3')->put($filePath, file_get_contents($file));
Also I added AWS Credentials in .env file.
Laravel version 6.0
I got following error when I upload file.
GuzzleHttp\Exception\ConnectException cURL error 28: (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Solution
I fixed the issue. Issue was AWS Credentials not reading from .env file. So I directly added in filesystem.php file.
's3' => [
'driver' => 's3',
'key' => 'KxxxxxxxN',
'secret' => 'fSFrxxxxxxxxxx',
'region' => 'us-east-1',
'bucket' => 'bucket-name',
'url' => 'http://s3.us-east-1.amazonaws.com/bucket-name',
],
Answered By - Shankar S Bavan Answer Checked By - Timothy Miller (WPSolving Admin)