Use PHP to upload images to qiniu,
Automatic loading class
<?phpfunction classLoader($class){ $path = str_replace('\\', DIRECTORY_SEPARATOR, $class); $file = __DIR__ . '/src/' . $path . '.php'; if (file_exists($file)) { require_once $file; }}spl_autoload_register('classLoader');require_once __DIR__ . '/Qiniu/functions.php';
Upload code:
<? Php /**
* Qiniu upload *
* $ AccessKey will be provided by qiniu upon application
* $ SecretKey will be provided by qiniu upon application
*
*/
Require_once _ DIR __. '. /Qiniu/Config. php '; require_once _ DIR __. '. /Qiniu/Auth. php '; require_once _ DIR __. '. /Qiniu/Storage/UploadManager. php '; require_once _ DIR __. '. /Qiniu/Zone. php '; require_once '. /autoload. php '; use Qiniu \ Auth; use Qiniu \ Storage \ UploadManager; $ accessKey = 'xxxxxxxx'; $ secretKey = 'xxxxxxxxxxxx'; $ auth = new Auth ($ accessKey, $ secretKey); // specify the key $ uploadMgr = new UploadManager (); $ bucke T = "unlock"; // space $ policy = array ("saveKey" => "$ (year) $ (mon) $ (day) $ (hour) $ (min) $ (sec)/$ (etag) "); $ token = $ auth-> uploadToken ($ bucket, null, 3600*3600, $ policy);?> <! DOCTYPE html>