app/Http/Controllers/API/UploadController.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)
    {
        $status = $request->input('decrypted');
        switch ($status){
            case 'success':
                break;
            case 'fail':
                return $this->jsonResponse(['Token invalid'],'Access Denied',403);
                break;
            case 'empty':
                return $this->jsonResponse(['Token missing'],'Unauthorized',401);
                break;
            default :
                return $this->jsonResponse(['Authenticate failed'],'Access Denied',403);
                break;
        }
        $validator = \Validator::make($request->all(), [
            'file' => 'required|max:5096|image'
        ]);
        if ($validator->fails()) {
            return $this->jsonResponse(['Image incorrect'],'Access Denied',403);
        }
        $path = $request->file('file')->store(date('Ym'),'public');
        $this->putSQL($path,$request->input('user_id'));
        return $this->jsonResponse(['url'=>config('app.url')."/FurPic/".$path,"time"=>time()],"操作成功");
    }
public function store ( Request $ request ) { $ status = $ request -> input ( 'decrypted' ) ; switch ( $ status ) { case 'success' : break ; case 'fail' : return $ this -> jsonResponse ( [ 'Token invalid' ] , 'Access Denied' , 403 ) ; break ; case 'empty' : return $ this -> jsonResponse ( [ 'Token missing' ] , 'Unauthorized' , 401 ) ; break ; default : return $ this -> jsonResponse ( [ 'Authenticate failed' ] , 'Access Denied' , 403 ) ; break ; } $ validator = \ Validator :: make ( $ request -> all ( ) , [ 'file' => 'required|max:5096|image' ] ) ; if ( $ validator -> fails ( ) ) { return $ this -> jsonResponse ( [ 'Image incorrect' ] , 'Access Denied' , 403 ) ; } $ path = $ request -> file ( 'file' ) -> store ( date ( 'Ym' ) , 'public' ) ; $ this -> putSQL ( $ path , $ request -> input ( 'user_id' ) ) ; return $ this -> jsonResponse ( [ 'url' => config ( 'app.url' ) . " /FurPic/ " . $ path , " time " => time ( ) ] , " 操作成功"); }
Store a newly created resource in storage.
Store a newly created resource in storage .
//