Franco Maldonado
Franco Maldonado

Reputation: 147

Can't upload files larger than 10MB via axios

I am trying to send a file larger than 10MB (which is the default maximum) via axios. This is my code:

let formData = new FormData();
                formData.append('files', this.file_xcode_ios);

                axios.post('/xcode_ios.php?timestamp=<?=$get_id;?>', formData, {
                headers: {'Content-Type': 'multipart/form-data'}
                  })

I am using this axios script (last version of axios 0.19.2)

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

I have read about:

maxContentLength: Infinity,
maxBodyLength: Infinity

But I can't make it work.

I get this error:

413 Request Entity Too Large

I would really appreciate if someone can help me fix this.

Upvotes: 0

Views: 9204

Answers (2)

Breno Melo
Breno Melo

Reputation: 31

maxContentLength: 10000000,
maxBodyLength: 10000000

I implemented on axios but don't can make http request with successfully , continue with error

Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limit

this is my code

axios.post(url, bodyFormData,{
                headers: {'Content-Type': 'multipart/form-data'},
                maxBodyLength: 10000000,
                maxContentLength: 10000000,
                emulateJSON: true
                
            })

Upvotes: 0

Gvs Akhil
Gvs Akhil

Reputation: 2591

In some of the forums I came across using

maxContentLength: 10000000,
maxBodyLength: 10000000

instead of

maxContentLength: Infinity,
maxBodyLength: Infinity

Upvotes: 4

Related Questions