vendredi 1 décembre 2017

how to fix Missing argument 4 for App\Http\Controllers\FilesController::saveUploads() in Laravel

I have file attachment form like following form actions.

<form class="form-vertical" role="form"
                                    enctype="multipart/form-data"
                                    method="post"
                                    action=" route('projects.files', ['taskId'=>$task->id])">
            <div class="form-group">
                <input type="file" name="file_name" class="form-control" id="file_name">
                @if ($errors->has('file_name'))
                    <span class="help-block"></span>
                @endif
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-info">Add Files</button>
            </div>
            <input type="hidden" name="_token" value="">
        </form>

and My FileController is this

public function uploadAttachments(Request $request,$id)
    {
       $this->validate($request, [
            'file_name'     => 'required|mimes:jpeg,bmp,png,pdf|between:1,7000',
        ]);

        $filename     = $request->file('file_name')->getRealPath();
        Cloudder::upload($filename, null);
        list($width, $height) = getimagesize($filename);
        $fileUrl = Cloudder::show(Cloudder::getPublicId(), ["width" => $width, "height" => $height]);
        $this->saveUploads($request, $fileUrl, $id);//line 36
        return redirect()->back()->with('info', 'Your Attachment has been uploaded Successfully');
    }

    private function saveUploads(Request $request, $fileUrl, $id,$taskId) //line 43
    {
        $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();

    }

but when I am going to attach files I got following errors.

 ErrorException in FilesController.php line 43: Missing argument 4 for App\Http\Controllers\FilesController::saveUploads(), called in C:\Users\John\Desktop\ddd\app\Http\Controllers\FilesController.php on line 36 and defined 

how can fix this problem?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iyE2aV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire