@Maryem What’s the issue? How you tried this yet?
May 11, 2017
3
Level 1
How to upload file PDF using laravel?
I have an application based on Laravel 5 with file upload functionality. 1. I try to insert images(jpeg,bmp,png) and files(Docx,xlsx) so Everything works fine except uploading of PDF files. 2. Need help on how to insert files (pdf) using laravel? I use laravel framework with Mysql
public function rules()
{
return [
'proposition' => 'required',];
$filename = count($this->input('filename'));
foreach(range(0, $filename) as $index) {
$rules['filename.' . $index] =
'required|mimes:pdf,jpeg,bmp,png,doc,docx,csv,xlsx|max:20000';
}
return $rules;
}
public function store(PropositionRequest $request)
{
$proposition = new Proposition();
$prop = Proposition::create($request->all());
$prop->saveTags($request->get('tags'));
foreach ($request->filename as $filename) {
$filename = $filename->store('filename');
PropositionFiles::create([
'proposition_id' => $prop->num_proposition,
'filename' => $filename
]);
}
Please or to participate in this conversation.