0
Well, I have a form that contains an html input of an image. When I send the form to Control, I do the image processing, taking his name and uploading to the image directory. More when I see in the bank the name of the image is not correct. See in the image beside ->
So with this problem I can not find the image, since the names do not match (The name of the directory != of the name of the bank). See how I am doing:
if ($request->hasFile('imagem')) {
$imagem = $request->file('imagem');
$filename = time() . '.' . $imagem->getClientOriginalExtension();
Image::make($imagem)->resize(100, 100)->save(public_path('/imagem/igreja/membros/' . $filename));
$all = $request->all();
$membro->imagem = $filename ;
$return = $membro->create(
$all
);
if ($return)
return redirect()->route('membro.index')->with('msg', 'Membro cadastrado com sucesso!');
else
return redirect()->back();
}
The information will, but the image won’t. I’m seriously afraid of having to do it that way:
$membro->create(['Imagem' => 'value','...' => '....' ] );
Because I have a large form and would mess up my controlller.
you are filling the variable
$filename
before save, that is, taking the directorytmp
image. Mount the directory that the image will be stored, pass this directory to the methodsave
and save him on the bench.– juniorb2ss
On this line I already have the name of the image. Maybe I didn’t mean what you mean. $filename = time() . '. ' . $imagem->getClientOriginalExtension() Soon after I thought of assigning the value $filename in $membro->imagem , and then saving. but he’s not going to the bank
– Natan Melo