I have file attachment form in My laravel app. in this form I am going to save project_id in to the file table also.
this is My form.blade.php
<form class="form-vertical" role="form"
enctype="multipart/form-data"
method="post"
action=" "> // this is line 41
<div class="form-group">
<input type="file" name="file_name" class="form-control" id="file_name">
</div>
<div class="form-group">
<button type="submit" class="btn btn-info">Add Files</button>
and my FileController methods is this
private function saveUploads(Request $request, $fileUrl, $id,$taskId)
{
$file = new File;
$file->file_name = $request->file('file_name')->getClientOriginalName();
$file->file_url = $fileUrl;
$file->project_id = $id;
$file->task_id = $taskId;
$file->save();
}
and routes
Route::post('projects/{projects}/tasks/{tasks}/files', [
'uses' => 'FilesController@uploadAttachments',
'as' => 'projects.files',
'middleware' => ['auth']
]);
but when I am going to submit file attach buttons it is generated following errors
ErrorException in 88ff5154a46f749c29024e0c9f84c577f7c5025e.php line 41: Undefined variable: task (View: C:\Users\John\Desktop\dddd\resources\views\files\form.blade.php)
how to fix this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire