首页 > 解决方案 > 图片上传到 TMP 文件位置不正确

问题描述

使用下面的代码,它应该上传到 $path 中指定的路径,但由于某种原因,它会将所有图片的链接保存到 c:\xampp\tmp,扩展名为 .tmp,但无论如何都会将它们移动到正确的文件夹中。我做错了什么?

public function store(Request $request){
        //
        if($file = $request->file('image')){
          $name = $file->getClientOriginalName();
          $path = 'public/images';
          if($file->move($path, $name)){
            $post = new Gallery();
            $post->image = $request->image;
            $post->name = $request->name;
            $post->species_id = $request->species_id;
            $post->tag = $request->tag;
            $post->patreon = $request->tag;
            $post->save();
            return redirect()->route('admin.gallery.index');
          };
        };
    }

标签: phplaravel

解决方案


推荐阅读