jeudi 28 avril 2016

Image is saving as tmp file in database laravel

Before explaining the problem. Let me show the controller function:

public function storePost(IdeaRequest $request)
{
   $idea = new Idea();
   $idea->idea_title       = $request->input('idea_title');
   $idea->user_id          = $request->input('user_id');
   $idea->idea_image       = $request->file('idea_image')->move('publicPages\images')->getClientOriginalName();
   $idea->idea_info        = $request->input('idea_info');
   $idea->selection        = $request->input('selection');
   $idea->idea_location    = $request->input('idea_location');
   $idea->idea_goal        = $request->input('idea_goal');
   $idea->idea_description = $request->input('idea_description');
   $idea->save();
   session()->flash('flash_message', 'Your idea has been submitted for Review');
   return back();
}

It stores the image as .tmp file. Things I have tried out

  • guessExtension(), It just returns the extension name and does not even store the image.

  • getClientOriginalName(), it throws an error; getClientOriginalName method is not defined. I have searched the method and it is in there. used its namespace Symfony\Component\HttpFoundation\File\UploadedFile. it did not work either.

  • Tried different things out from stackoverflow, Nothing has worked for me till now. In other words, i have invested a lot of time to solve this problem but nothing worked. Any help would highly be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire