I'm trying to upload image via Model
such as :
use File;
use Image;
use Response;
use Illuminate\Database\Eloquent\Model;
/* -------------------------------------------- */
public function upload_image($filename)
{
$destinationPath = base_path() . '/upload/';
$fileName = time() . '_' . $filename->getClientOriginalName();
$uploadSuccess = Image::make($filename)->save($destinationPath . $fileName);
if ($uploadSuccess)
return $fileName;
else
return false;
}
Controller:
public function store(StoreMerchantWebServiceRequest $request)
{
$file = $request->file('photo');
$data = new Merchant();
$filename = $data->imageUpload($file);
$data->company_name = $request->input('agent_company_name');
$data->company_logo = $filename;
$data->user_id = Auth::user()->id;
$data->save();
return redirect()->route('merchantsWebService.index');
}
Unfortunately i get this error:
FatalErrorException in Merchant.php line 59: Call to a member function getClientOriginalName() on a non-object
My form:
{!! Form::open(
[
'route' => [
'merchantsWebService.store'],
'method' => 'POST',
'enctype'=>'multipart/form-data',
'class'=>'validate',
'files' => true,
'id'=>'xfrm_submit'
]
)
!!}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Iusc24
via IFTTT
Aucun commentaire:
Enregistrer un commentaire