I need to submit a form with multiple files to the database in Laravel,each time i fill the form i got this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: insert into
add_file
(0
) values ({"name":"Opeyemi Adam","description":"Thanks bro","attach":[["CRITICAL TECHNICAL OBSERVATIONS.doc"]]}))
Below is the Model
class AddFile extends Model{
protected $table = 'add_file';
protected $fillable = ['name', 'description', 'attach'];
}
Controller
public function submitform(AddFileFormRequest $request){
$destinationPath = storage_path('app/attachments/');
$attach_file = array();
$file = $request->file('attach');
if (!empty($file[0])){
foreach($file as $key){
$filename = $key->getClientOriginalName();
$key->move($destinationPath, $filename);
$attach_file[] = array($filename);
}
}
$form_content = new AddFile(array(
'name' => $request->get('name'),
'description' => $request->get('description'),
'attach' => $attach_file
));
var_dump($form_content);
DB::table('add_file')->insert(array($form_content));
}
Don't know where the field list is coming from
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire