Laravel uploads files to Qiniu Cloud Storage
Public function store (Request $ request) {$ file = $ request-> file ('photo'); if (! $ File-> isValid () {return back () ;}// enter your Access Key and Secret Key $ accessKey = 'cifdxnihyc5wljfqtgzcft8dqy01a-xyFLyr71b '; $ secretKey = 'kbbk5jbf-G45QxWZza3H6zC_cl82vrMpa7f _ QEQ '; // Construct an authentication object $ auth = new Auth ($ accessKey, $ secretKey ); // the space to be uploaded $ bucket = 'laravel'; // Generate the upload Token $ token = $ auth-> uploadToken ($ bucket ); // Local path of the file to be uploaded $ filePath = $ file-> getRealPath (); // file name saved after being uploaded to Qiniu $ key = time (). ran D (999,9999 ). ". jpg "; // initialize the UploadManager object and upload the file $ uploadMgr = new UploadManager (); // call the putFile method of UploadManager to upload the file list ($ ret, $ err) = $ uploadMgr-> putFile ($ token, $ key, $ filePath); echo "\ n ===> putFile result: \ n"; if ($ err! = Null) {var_dump ($ err);} else {$ photo =' http://ddd.clouddn.com/ '. $ Ret ['key']; var_dump ($ ret );}}