Level 6
dd($request->all());
do this before the validation and let us know what you see(screeenshot)
I suspect that the solution may be obvious but I Am not winning. Please assist to solve this issue. I want to save a book with image(image works well) and pdf (which is not uploading because of the error)
How can save/store pdf and image at the same time?
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required',
'price' => 'required',
'image' => 'required|image',
'file_name' => 'required',
]);
$book = new Book;
// Upload Image
if($request->hasFile('image')){
$image_tmp = Input::file('image');
if ($image_tmp->isValid()) {
// Upload Images after Resize
$extension = $image_tmp->getClientOriginalExtension();
$book_image_new_name = rand(111,99999).'.'.$extension;
$image = 'uploads/books'.'/'.$book_image_new_name;
Image::make($image_tmp)->save($image);
$book->image = $book_image_new_name;
}
}
//Upload i want to upload a pdf please help
$file = $request->file('pdf');
$destinationPath = 'uploads/books';
$file->move($destinationPath,$file->getClientOriginalName()); // this line here is the problem or throws an error
$book->name = $request->name;
$book->description = $request->description;
$book->price = $request->price;
$book->pages = $request->pages;
$book->author = $request->author;
$book->isbn = $request->isbn;
$book->publisher = $request->publisher;
$book = $request->file('pdf');
$book->image = 'uploads/books/' . $book_image_new_name;
$book->save();
Session::flash('success', 'Book created.');
return redirect()->back()->with('msg','Book added successfully');
}
Please or to participate in this conversation.