What is the function to upload images in Laravel 5.1

I want to upload an image in database and also into a specific folder. I studied many tutorials but I did not find specific answer. So please help me. I tried $request->file('image')->move($destinationPath, $fileName); but it doesn’t work.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try this:

Input::file('photo')->move($destinationPath, $fileName);

OR
Input::file('photo')->move($destinationPath);

Here,
photo will be your image, you want to save.

$destinationPath: Where you want to store your uploaded image

$fileName: Your image filename (optional)

Your Form, through which you are uploading the file, should be in this format:

{!! Form::open(array('name'=>'create', 'method'=>'POST', 'files'=>true, 'url'=>'some/path')) !!}

{!! Form::close() !!}

See, if that helps. (For More info see here)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x