why does it not work? on first glance it seems to be ok.
is business_card in your $fillable array?
by the way, there is a slug helper to make strings safe in urls etc
I want to save image file name in db here is the function for upload image
//file upload
public function imgUploader($FileToUpload)
{
//define main image path
$destinationPath = public_path(). '/uploads/img/';
//define thumbnail path
$thumbs = public_path(). '/uploads/img/';
// $gallery = public_path(). '/uploads/items/gallery/';
//get image
$file = $FileToUpload;
//rename image, remove spaces and converto to loawer case
$filename =
date('Y_m-d_His').'_'.
strtolower(str_replace(' ', '_', $file->getClientOriginalName()));
//move file to main image path
$file->move($destinationPath, $filename);
//generate thumbnail
Image::make($destinationPath.$filename)->resize('640', '448')->save($destinationPath.$filename);
// Image::make($destinationPath.$filename)->resize('850', '371')->save($gallery.$filename);
return $filename;
}
here is function for save data from this form
public function updateCompanyProfile(Request $request)
{
$companyprofile = CompanyProfile::where('company_id',$this->getCompanyID())->first();
$companyprofile->business_card = $this->imgUploader();
$input = Input::only('company_name', 'address_1', 'address_2', 'city', 'zip',
'state', 'country', 'area', 'phone', 'fax', 'email', 'website', 'business_card');
try {
$companyprofile->fill($input)->save();
Session::flash('flash_message', 'Information Updated successfully!');
} catch (ModelNotFoundException $e) {
// return view('pages.status')
// ->with('error',\Lang::get('profile.notYourProfile'))
// ->with('error_title',\Lang::get('profile.notYourProfileTitle'));
Session::flash('flash_message', 'Error!!!');
}
return redirect::back();
}
how i can change it for save image in db and upload it on my folder as well
Sorry the last line should be
$companyprofile->update($record);
and not the request all
So it shoudl be
try {
$record = $request->all();
if($request->file('business_card'))
{
$record['business_card'] = $this->imageUploaders($request->file('business_card'));
}
return $companyprofile->update($record);
}
Please or to participate in this conversation.