这是我上传858 KB文件的场景,但在Controller中它是0kb,当我在storage_path()中保存时,它是空的
我正在将图像保存在/storage上,它已经损坏了,如何修复它?
//this is the controller
$input = $request->all();
echo $request->file('image_path')->getClientSize();
dd($input);**这是dd **0的返回。
"image_path" => UploadedFile {#30 ▼-originalName: "Tulips.jpg"mimeType:"application/octet-stream"-size: 0-error: 6//这是带有刀片形状的视图
{!! Form::open(array('url' => 'test2', 'files'=> true)) !!}
<div class="form-group">
{!! Form::text('title',Input::old('title'),['class'=>'form-control', 'placeholder' => 'What is your title?']) !!}
</div>
<div class="form-group">
{!! Form::label('image', 'Your Image') !!}
{!! Form::file('image_path') !!}
<p class="help-block">Hey! Please don't upload over 15MB images!</p>
</div>
<div class="form-group">
{!! Form::label('caption', 'Don\'t miss to caption!') !!}
{!! Form::text('caption',Input::old('caption'),['class'=>'form-control', 'placeholder' => 'Your caption']) !!}
</div>
{!! Form::submit('Post now!',['class'=>'btn btn-info']) !!}
{!!Form::close() !!}//我也尝试使用html表单
<form id="pdf" action="{{ route('test2') }}" method="POST"enctype="multipart/form-data">
<input type="file" name="image_path">
<span id="imgName">Choose a File</span>
<input type="text" name="_token" value="
{{csrf_token()}}">
<input type="file" name="image_path"
id="path" />
<input type="submit" />发布于 2019-07-10 07:54:00
getClientSize()在Laravel不受欢迎。使用$request->file('image_path')->getSize();
正如它在Laravel来源中提到的那样。
/**
* Returns the file size.
*
* It is extracted from the request from which the file has been uploaded.
* Then it should not be considered as a safe value.
*
* @deprecated since Symfony 4.1, use getSize() instead.
*
* @return int|null The file sizes
*/
public function getClientSize()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use getSize() instead.', __METHOD__), E_USER_DEPRECATED);
return $this->getSize();
}发布于 2019-07-11 01:09:16
我已经确定了问题所在,在IIS中,version.It被设置为php7.2,在我将它更改为php5.5之后,它就工作了
https://stackoverflow.com/questions/56965682
复制相似问题