Document not uploading



  • Hello,
    I am trying to upload the files on the location "public\storage\new_documents\type_one", but my documents are not saved in public folder.
    I have checked the post request, getting all the data including the file data. Also added enctype='multipart/form-data' in the form.



  • Hi @ppstech

    Can you show your code of uploading files ?

    Thanks



  • This is my code

    if($request->hasfile('crdocument')) {
                $filenameWithExt = $request->file('crdocument')->getClientOriginalName();
                //get file name
                $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
                //get extension
                $extenson = $request->file('crdocument')->getClientOriginalExtension();
                // filename to store
                $fileimagetostore = $filename.'_'.time().'.'.$extenson;
                //upload the image
                $criddoc_path = $request->file('crdocument')->storeAs('public/new_documents/type_one',$fileimagetostore);
            }else{
                $fileimagetostore = "Nodoc.jpg";
            }
    


  • Hi @ppstech

    Try this one -

    if (request()->hasfile('file')) {
         $filenameWithExt = request()->file('file')->getClientOriginalName();
    
         //get file name
         $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
    
         //get extension
         $extenson = request()->file('file')->getClientOriginalExtension();
              
         // filename to store
         $fileimagetostore = $filename.'_'.time().'.'.$extenson;
    
        //upload the image
         $criddoc_path = request()->file('file')->storeAs('public/new_documents/type_one',$fileimagetostore);
      } else{
            $fileimagetostore = "Nodoc.jpg";
    }
    

    Thanks


Log in to reply