So I am trying to save uploaded image to laravel/public folder and return src so a path to where the file has been saved, however nothing happens after I choose an image and I get no errors, what might be wrong?
public function testing(Request $request) {
if(Input::file())
{
$image = Input::file('img');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('images/' . $filename);
Image::make($image->getRealPath())->resize(200, 200)->save($path);
$user->image = $filename;
$user->save();
}
}
<form action="{{ action('BuilderController@testing') }}" enctype="multipart/form-data" role="form" method="POST">
<input id="img" class="form-control filestyle margin images" data-input="false" type="file" data-buttonText="Upload Logo" data-size="sm" data-badge="false" onchange="uploadImage();" />
</form>
Try with move()
method?
$filename = time().'.'.request()->img->getClientOriginalExtension();
request()->img->move(public_path('images'), $filename);
$user->image=$filename;
$user->save();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With