upload-file.js 530 B

1234567891011121314151617181920212223
  1. Page({
  2. uploadFile() {
  3. my.chooseImage({
  4. chooseImage: 1,
  5. success: res => {
  6. const path = res.apFilePaths[0];
  7. console.log(path);
  8. my.uploadFile({
  9. url: 'http://httpbin.org/post',
  10. fileType: 'image',
  11. fileName: 'file',
  12. filePath: path,
  13. success: res => {
  14. my.alert({ title: '上传成功' });
  15. },
  16. fail: function(res) {
  17. my.alert({ title: '上传失败' });
  18. },
  19. });
  20. },
  21. });
  22. },
  23. });