文件上传

底层自动协程调度, 可支持异步发送超大文件, 断点续传

同时上传三个文件(三种参数风格string| array |object)

  1. $file1 = __DIR__ . '/black.png';
  2. $file2 = [
  3. 'path' => __DIR__ . '/black.png',
  4. 'name' => 'white.png',
  5. 'type' => ContentType::MAP['png'],
  6. 'offset' => null, //re-upload from break
  7. 'size' => null //upload a part of the file
  8. ];
  9. $file3 = new SwUploadFile(
  10. __DIR__ . '/black.png',
  11. 'white.png',
  12. ContentType::MAP['png']
  13. );
  14. echo SaberGM::post('http://httpbin.org/post', null, [
  15. 'files' => [
  16. 'image1' => $file1,
  17. 'image2' => $file2,
  18. 'image3' => $file3
  19. ]
  20. ]
  21. );