How to change name of file in javascript from input=File

后端 未结 3 1010
情深已故
情深已故 2021-02-01 19:29

I need to change the filename (not the file, just the metadata of the name) when uploading to a sharepoint site.

I figured that it would be easy enough to change the htm

3条回答
  •  不思量自难忘°
    2021-02-01 20:13

    try this:

    var element = document.GetElementById('fileupload1');
    var file = element.files[0];
    var blob = file.slice(0, file.size, 'image/png'); 
    newFile = new File([blob], 'name.png', {type: 'image/png'});
    

    note: this is for a image type, you have to change this type with type you're actually using.

提交回复
热议问题