question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

posting with formdata not working

See original GitHub issue

tried doing something like

var fileData = new FormData();
      fileData.append("File1", file);

return axios({
                    method: 'post',
                    url: response.data.ChunkUri,
                    data: fileData,

                });

this returned an error from the server saying that there was no file sent. But…

vs jquery which worked and the file uploaded successfully.


                var options = {
                    type: "POST",
                    url: response.data.ChunkUri,
                    data: fileData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function(e){
                            console.log("YAY:: " + e);
                    },
                    error: function(a){
                        console.log("failed:: ");
                    }

                };
                return $.ajax(options);

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
nickuraltsevcommented, Apr 2, 2016

As @kalaspuffar pointed out, filename can be passed as the third parameter to FormData#append:

fileData.append("File1", file, "file.js");
1reaction
ConAntonakoscommented, Jul 7, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

formData object not working with jquery AJAX post?
When you're sending an ajax request via jQuery and you want to send FormData you don't need to use JSON.stringify on this FormData....
Read more >
formData not working , after append , i got empty form data
This is my code var formData = new FormData(); formData.append('file',file); var options = { data:{"file":formData} } console.log(formData); ...
Read more >
FormData() - Web APIs - MDN Web Docs - Mozilla
The FormData() constructor creates a new FormData object.
Read more >
Form data is empty while posting form through ajax using ...
We'll need to see your HTML to diagnose this, if your console.log is returning null then you've got a mistake in how you're...
Read more >
Form Container - Post Form Data - Not working in AEM
Third point that you should be aware once you are using Post form data - this supports only endpoints that dose not require...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found