I want to create an uploader with js. Can anyone help me how to upload a file using javascript?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can upload files with
XMLHttpRequest
andFormData
. The example below shows how to upload a newly selected file(s).Disclaimer, I'm the author of FilePond and this is very similar to how it does uploading as well.
You can use html5 file type like this:
You file will be in value:
For more information see https://www.w3schools.com/jsref/dom_obj_fileupload.asp
and see example here: https://www.script-tutorials.com/pure-html5-file-upload/