multipart.php 670 B

12345678910111213141516171819202122
  1. <?php
  2. require_once("../ucloud/conf.php");
  3. require_once("../ucloud/http.php");
  4. require_once("../ucloud/proxy.php");
  5. //存储空间名
  6. $bucket = "your bucket";
  7. //上传至存储空间后的文件名称(请不要和API公私钥混淆)
  8. $key = "your key";
  9. //待上传文件的本地路径
  10. $file = "local file path";
  11. //该接口适用于web的POST表单上传,本SDK为了完整性故带上该接口demo.
  12. //服务端上传建议使用分片上传接口,而非POST表单
  13. list($data, $err) = UCloud_MultipartForm($bucket, $key, $file);
  14. if ($err) {
  15. echo "error: " . $err->ErrMsg . "\n";
  16. echo "code: " . $err->Code . "\n";
  17. exit;
  18. }
  19. echo "ETag: " . $data['ETag'] . "\n";