app/Http/Controllers/GalleriController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $galleri = new Galleri;
        $galleri->photos = $request->photos;
        if($request->hasFile('photos')) {
            $file = $request->file('photos');
            $destinationPath = public_path() .DIRECTORY_SEPARATOR. 'img';
            $filename = str_random(6).'_'.$file->getClientOriginalName();
            $uploadSuccess = $file->move($destinationPath, $filename);
            $galleri->photos = $filename;
        }
        $galleri->save();
        return redirect()->route('galleri.index');
    }
public function store ( Request $ request ) { $ galleri = new Galleri ; $ galleri -> photos = $ request -> photos ; if ( $ request -> hasFile ( 'photos' ) ) { $ file = $ request -> file ( 'photos' ) ; $ destinationPath = public_path ( ) . DIRECTORY_SEPARATOR . 'img' ; $ filename = str_random ( 6 ) . '_' . $ file -> getClientOriginalName ( ) ; $ uploadSuccess = $ file -> move ( $ destinationPath , $ filename ) ; $ galleri -> photos = $ filename ; } $ galleri -> save ( ) ; return redirect ( ) -> route ( 'galleri.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//upload foto