Support the ongoing development of Laravel.io →
Input Database Forms
Last updated 1 year ago.
0

Validation: This is not the correct syntax. You are validating the fields 'image', 'mime' and 'max'. Please read the docu

http://laravel.com/docs/4.2/validation

As you can see, multiple rules for a field are separated by a pipe character '|' or as separate elements of an array. Your syntax should look something like this

$rules = array('image' => 'required|mimes:jpeg,jpg,png|max:200px');

or this (please notice the array inside the array)

$rules = array('image' => array('required', 'mimes:jpeg,jpg,png', 'max:200px'));

As for the db: This is a too wide topic to discuss here. You may check out this tut, which is for Laravel 5, but the creation of db table and the saving of an uploaded image/file is valid for L4 and L5.

http://www.codetutorial.io/laravel-5-file-upload-storage-downl...

Essentially, you create a new instance of your image/file model

$image = new MyImageModel();

you add data, i.e. fill the columns of the db table

$image->column1 = $data1;
$image->column2 = $data2;
...

and finally you use Laravel's Eloquent to save the model

$image->save();
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ubilli ubilli Joined 10 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.