【发布时间】:2017-03-04 09:08:08
【问题描述】:
基本上我想上传一张图片并将其显示给用户,在选择图片的那一刻,什么都没有发生我没有收到错误错误或其他任何东西,我想知道发生了什么。
这是我的代码:
<form action="{{ action('BuilderController@testing') }}" role="form" method="POST">
<input class="form-control filestyle margin images" data-input="false" type="file" data-buttonText="Upload Logo" data-size="sm" data-badge="false" />
</form>
<div class="logo">
<img class="images" id="image" src="#" alt="Your Logo"/>
</div>
控制器:
public function testing() {
if(Input::file())
{
$image = Input::file('photo');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('images/' . $filename);
Image::make($image->getRealPath())->resize(200, 200)->save($path);
$user->image = $filename;
$user->save();
}
}
【问题讨论】:
-
试试这个插件blueimp.github.io/jQuery-File-Upload 很不错很简单
-
更大尺寸需要它
标签: laravel laravel-5 laravel-5.3