Guest User

Untitled

a guest
Apr 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. var dataForm = new FormData();
  2.  
  3. dataForm.append("metadata", JSON.stringify({
  4. "fileName": attachment.files[0].name,
  5. }));
  6.  
  7. dataForm.append("file", attachment.files[0]);
  8.  
  9. $.ajax({
  10. url: "http://mipagina.openproject.com/api/v3/work_packages/{ID}/attachments",
  11. method: "POST",
  12. enctype: 'multipart/form-data',
  13. processData: false,
  14. data: dataForm,
  15. cache: false,
  16. success: function (data) {
  17. console.log(dataForm);
  18. console.log(data);
  19. },
  20. error: function () {
  21. console.log("error");
  22. }
  23. });
Add Comment
Please, Sign In to add comment