I am using the krajee, ajax file input plugin with laravelframwork.when i m click on upload button so it gives an error of "create default object from empty value". If anyone know about this error how to resolve it kindly reply me. My html code is;
Scripts code is;
$("#input-700").fileinput({
uploadUrl: "", // server upload action
uploadAsync: true,
initialPreview: s.photoInitialPreview,
previewFileType: "image",
initialPreviewAsData: true,
data: {'_token': ""},
maxFileCount: 4,
uploadExtraData: {'_token': ""}
});
And my controller code is; public function productImage(Request $request) {
$productImage = new ProductImage;
$file = Input::file('image_path');
$productImage = $request->product_id;
if ($file) {
$userId = Auth::user()->id;
$destinationPath = public_path('assets/uploads/' . $userId . '/images/');
$filename = $userId . '-' . time() . "." . $file->getClientOriginalExtension();
$file->move($destinationPath, $filename);
$productImage->image_path = $filename;
}
$productImage->save();
// return redirect()->back(); }
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire