Laravel 上传文件缩略图

这里需要注意两个地方:

  • 表单提交方式需要是 post
  • form 添加一个属性为 enctype="multipart/form-data"

在 index.html 加入input 标签

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<h1>hello worlds</h1>
<form action="/app/upload" method="post" enctype="multipart/form-data">
@csrf
<p><input type="file" name="upload"></p> <p><input type="submit" value="submit"></p> 

</form> 
</body>
 </html>

public function uploadFile(Request $request){
    $path = $request->file('upload')->store('avatars');
    return $path;
}

 https://www.cnblogs.com/wxy0126/p/10698304.html

Intervention Image

http://image.intervention.io/getting_started/installation

https://www.cnblogs.com/jinxiblog/p/8053008.html

http://image.intervention.io/getting_started/installation

posted on 2021-02-25 09:48  防空洞123  阅读(73)  评论(0编辑  收藏  举报

导航