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   防空洞123  阅读(74)  评论(0编辑  收藏  举报

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示