Image uploads to tmp instead of correct location

Posted 2 months ago by MattB

Using the below code, it should upload to the path specified in $path but for some reason, it saves the links to all pictures to c:\xampp\tmp with the .tmp extension but will move them to the correct folder anyway. What have I done wrong?

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');
          };
        };
    }

Please sign in or create an account to participate in this conversation.