我尝试过使用此链接https://www.5balloons.info/example-file-upload-validation-laravel-5-6/
我设法通过尝试返回FileName来解决问题,但问题是我尝试上传的文件未显示在“storage / app”文件夹中
这是我的代码
控制器
public function letterOfIntent(Request $request)
{
$fileName = "fileName".time().'.'.request()->fileToUpload->getClientOriginalExtension();
$request->fileToUpload->storeAs('logos',$fileName);
return 'success';
}
查看
<form method="post" action="/supplier-information/company-officer/letter-of-intent" method="post" enctype="multipart/form-data" data-form-method="create">
{{ csrf_field() }}
<div class="row">
<div class="col-lg-offset-1 col-lg-4">
<label style="color:tomato;">Letter of Intent</label>
<input type="file" class="form-control-file" name="fileToUpload" id="exampleInputFile" aria-describedby="fileHelp">
<small id="fileHelp" class="form-text text-muted">Please upload a valid image file. Size of image should not be more than 2MB.</small>
</div>
<div class="col-lg-3">
<label>Date of Validity</label>
<input class="form-control" type="date" name="upload_file" id="upload_file" class="form-control">
</div>
<div class="col-lg-3">
<br>
<button type="submit" class="btn btn-primary btn-lg btn-flat text-contrail">Upload</button>
<button type="submit" class="btn btn-success btn-lg btn-flat text-contrail">View</button>
</div>
</div>
</form>