PaulCatalin97
4 months ago

Uploading a file error

Posted 4 months ago by PaulCatalin97

So, I try to upload a file and shows me this error ! {"_token":"xBDlGKupDvKE3FPI84Eku5Kd6I6l5pKlRHs9LzCk","image":{}} what can i do to solve this ?

class UploadCvController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }
    public function index()
    {
        $profilecv = ProfileEmployee::where('uid', Auth::user()->id)->first();
        return view('uploadcv', compact('profilecv'));
    }

    public function update(Request $request)
    {
        $request->validate([
            'cv' => 'file', 'max:2048',
        ]);
        dd($request);
        $employeecv = ProfileEmployee::where('uid', Auth::user()->id)->first();

        if ($request->hasfile('cv')){
            $file = $request->file('cv');
            $extension = $file->getClientOriginalName();
            $filename = md5(time()).'.'.$extension;
            $file->move('C:\xampp\htdocs\apcjobs\public\cv',$filename);
            $employeecv->cv=$filename;
        } else {
            return $request;
            $employee->cv='';
        }
        $employeecv->save();

        if($employeecv){
            return redirect()->route('uploadcv')->withSuccess('S-a incarcat cu success!');
        }else{
            return redirect()->back()->withDanger('Nu s-a incarcat! A aparut o eroare.');
        }
    }

}

How can I convert the file or what can i do ? I dd($request) and says that i receive an image, but I upload a word.docx

Please sign in or create an account to participate in this conversation.