app/Http/Controllers/file.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)
    {
        $data = new \App\File();
		$data->name = $request->input('name');
		$file = $request->file('file');
		$ext = $file->getClientOriginalExtension();
		$newName = rand(100000,1001238912).".".$ext;
		$file->move('uploads/file',$newName);
		$data->file = $newName;
		$data->save();
		return redirect()->route('file.index')->with('alert-success','Data berhasil ditambahkan!');
    }
public function store ( Request $ request ) { $ data = new \ App \ File ( ) ; $ data -> name = $ request -> input ( 'name' ) ; $ file = $ request -> file ( 'file' ) ; $ ext = $ file -> getClientOriginalExtension ( ) ; $ newName = rand ( 100000 , 1001238912 ) . " . " . $ ext ; $ file -> move ( 'uploads/file' , $ newName ) ; $ data -> file = $ newName ; $ data -> save ( ) ; return redirect ( ) -> route ( 'file.index' ) -> with ( 'alert-success' , 'Data berhasil ditambahkan!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .