Skip to content

Instantly share code, notes, and snippets.

@segun6060
Last active March 8, 2017 07:20
Show Gist options
  • Save segun6060/b1ca5847298bcfbf0fc4e32f7c425aa8 to your computer and use it in GitHub Desktop.
Save segun6060/b1ca5847298bcfbf0fc4e32f7c425aa8 to your computer and use it in GitHub Desktop.
public function store(Request $request)
{
$image = new Image;
$image->user_id = Auth::user()->id;
if($request->hasFile('imageproof')) {
$proof = $request->file('imageproof');
$filename = time().'.'.$proof->getClientOriginalExtension();
$location = public_path('images/',$filename );
Image::make($proof)->resize(800, 400)->save($location);
$image->filePath=$filename;
} else {
return 'Image Proof not found';
}
$image->save();
return 'Image Uploaded Successfully';
}
<form action="/store" enctype="multipart/form-data" method="post">
<div class="form-group">
<h4 class="help-block">Uplaod proof of payment after paying.</h4>
<label for="exampleInputFile">File input</label>
<input type="file" name="imageproof" id="exampleInputFile">
{{csrf_field()}}
</div>
<button type="submit" class="btn btn-default">Upload</button>
</form>
Route::post('store', 'HomeController@store' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment