0

What is the best and most efficient way to upload large video, audio or pdf file to my laravel backend using javascript vuejs to be precise?.

I'm currently trying to convert the file to base64 but the issue that i am having is that the string becomes very long and i get a 413 payload too large error.

  • Could you send it in smaller chunks? – Peter Nov 22 '18 at 23:12
  • how will i do that...can you assist me.. – Dayana Scott Nov 22 '18 at 23:16
  • Maybe. Can you show us what your current solution looks like where you are getting the 413 issue? – Peter Nov 22 '18 at 23:22
  • 1
    Base64 is always larger than the original file. It is not compression but just encoding (with overhead) – online Thomas Nov 22 '18 at 23:24
  • Just use FormData and `multipart/form-data`. As mentioned, base64 encoding will increase the size of the request content. – M. Eriksson Nov 22 '18 at 23:33
  • uploadVideo(e, fileType, index, indexes){ if(fileType === 'audio'){ let reader = new FileReader(); let file = e.target.files[0]; reader.onload = (event) => { for(let i = 0; i < this.product.videoContent.length; i++){ this.product.videoContent[index].videoEpisode[indexes].videoFile = event.target.result; } } reader.readAsDataURL(file); } } i am looping through an array within array...thanks in advance – Dayana Scott Nov 22 '18 at 23:35
  • thanks for the reply @MagnusEriksson – Dayana Scott Nov 22 '18 at 23:57
  • Possible duplicate of [How to convert image into base64 string using javascript](https://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript) – pellul Nov 23 '18 at 01:13
  • [Here's a complete example of a file CRUD app in laravel and vue from Feb 2018.](https://codeburst.io/upload-and-manage-files-with-laravel-and-vue-915378c8b2a4) The code is on github. Maybe you can borrow the file upload parts. – ourmandave Nov 23 '18 at 02:12
  • thanks @ourmandave...it was really helpful – Dayana Scott Nov 24 '18 at 20:31

0 Answers0