Files Uploading on Amazon S3 server using Laravel 5.4 Part-2

Files Uploading on Amazon S3 server using Laravel 5.4 Part-2

In this Post We Will Explain About is Files Uploading on Amazon S3 server using Laravel 5.4 Part-2 With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Laravel 5 amazon s3 file upload Step By step Example

In this post we will show you Best way to implement php – Laravel 5.4:file upload to into aws s3 directly to bucket, hear for Uploading Directly To Amazon S3 From Laravel 5 Applicationwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

In this Second part I have last two step to make controller and crate blade view file for file simple upload file or video on amazon s3 server using Laravel 5 FileSystem.

Also Read :  Ajax Upload Multiple Images without form submitting

In this Last second step, we shall use “Storage” Mode facade for all the upload file in simple amazon s3 server as well as also get CDN Mode url of uploaded All the files. Therefore Now follow simple bellow source code two step for full example finish of upload laravel using image upload in s3 server.

Step 5: Create Controller

In this last second point, now we need to make new controller as liveIMAGESs3Ctrl in this simple path app/Http/Controllers/liveIMAGESs3Ctrl.php. this view controller will manage all the layout and upload image validation with post data request, So run simple bellow command for success generate new controller:

Also Read :  PHP Laravel 5.6 Image Upload with Validation Example

php artisan make:controller liveIMAGESs3Ctrl

Ok, Ad then put bellow some content in controller file:

Following Path :app/Http/Controllers/liveIMAGESs3Ctrl.php

validate($request, [
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);

        $your_imgname = time().'.'.$request->image->getClientOriginalExtension();
        $image = $request->file('image');
        $t = Storage::disk('s3')->put($your_imgname, file_get_contents($image), 'public');
        $your_imgname = Storage::disk('s3')->url($your_imgname);

    	return back()
    		->with('success','Good Luck.!!Image Uploaded successfully.')
    		->with('path',$your_imgname);
    }
}

Step 6: Create View



	<title>step By step Laravel 5.3 Amazon S3 Image or video  Upload with Validation step by step  example</title>
	


<!-- Devloped by Pakainfo.com-->
<div class="container">
  <div class="panel panel-primary">
    <div class="panel-heading"><h2>Laravel 5.3 Amazon S3 Image Upload with Validation example</h2></div>
<!-- Devloped by Pakainfo.com-->
    <div class="panel-body">

      @if (count($errors) > 0)
	 <div class="alert alert-danger">
	    <strong>Whoops!</strong> There were some problems with your input.<br><br>
		<ul>
		  @foreach ($errors->all() as $error)
		    <li>{{ $error }}</li>
		  @endforeach
		 </ul>
	    </div>
      @endif
<!-- Devloped by Pakainfo.com-->
	  @if ($data_message = Session::get('success'))
		<div class="alert alert-success alert-block">
			<button type="button" class="close">×</button>
		        <strong>{{ $data_message }}</strong>
		</div>
		<img src="get('path') }}">
	  @endif
<!-- Devloped by Pakainfo.com-->
	  <form action="{{ url('s3-image-upload') }}" enctype="multipart/form-data" method="POST">
		{{ csrf_field() }}
		<div class="row">
			<div class="col-sm-12">
				
			</div>
			<div class="col-sm-12">
				<button type="submit" class="btn btn-success">File Upload</button>
			</div>
		</div>
	  </form>
    </div>

  </div>
</div>
<!-- Devloped by Pakainfo.com-->


Now I Am ready to simple run your example therefor run bellow simple command ro all application quick run:

Also Read :  Inline Table Editing Row using Vuejs

php artisan serve

Now I can open this bellow URL on Mozila your browser:

http://localhost:8000/s3-image-upload

Example

I hope you have Got What is amazon s3 Server Uploading Files using Laravel 5.4 And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.