mercredi 4 mars 2020

when i try to upload the pdf file it trhows an error saying File not found at path

I am trying to upload the pdf and my doc file on the website. I did use the symlink to create a storage folder in public and created a folder called Paper so that the file uploaded can be saved in storage.

   <form class="form-horizontal" method="post" action="paper"enctype="multipart/form 
data">
@csrf
<div class="form-group">
    <label for="title">Title of Paper</label>
    <input type="text" class="form-control" name="title"  placeholder="Title of 
  Paper" required="required">
</div>
<div class="form-group">
    <label for="Paper">Upload Paper</label>
    <input type="file" class="form-control" name="paper" required="required" >
</div>

<button type="submit" class="btn btn-primary">Submit</button>

This is my controller code

namespace App\Http\Controllers;
use App\Submission;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
 class PapersController extends Controller
 {


 public function  store(Request $request){

$request->validate([
    'title'=>'required',
    'paper'=>'required'

]);


$title= $request->input('title');
 $request->validate([
        'paper' => 'required|mimes:pdf,xlx,csv|max:2048',
    ]);

      $fileName= time().'.'.$request->paper->extension();

      Storage::disk('local')->move(public_path('Paper'), $fileName);
      $newsubmission= array("title"=>$title, "paper"=>$fileName);
    $created= DB::table('submissions')->insert($newsubmission);
if($created){
    return "Sucessful";
}else{
    return "Not Sucessful";
}

}

But I am getting an error saying that file not found at the path. Any kind of help is appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire