fileapi

How to upload and list directories at firefox and chrome/chromium using change and drop events

为君一笑 提交于 2019-11-26 01:45:50
问题 Both mozilla and webkit browsers now allow directory upload. When directory or directories are selected at <input type=\"file\"> element or dropped at an element, how to list all directories and files in the order which they appear in actual directory at both firefox and chrome/chromium, and perform tasks on files when all uploaded directories have been iterated? 回答1: You can set webkitdirectory and allowdirs attributes at <input type="file"> element; attach change , drop events to <input

How to get a file or blob from an object URL?

余生颓废 提交于 2019-11-26 01:13:50
问题 I am allowing the user to load images into a page via drag&drop and other methods. When an image is dropped, I\'m using URL.createObjectURL to convert to an object URL to display the image. I am not revoking the url, as I do reuse it. So, when it comes time to create a FormData object so I can allow them to upload a form with one of those images in it, is there some way I can then reverse that Object URL back into a Blob or File so I can then append it to a FormData object? 回答1: As gengkev

How to set File objects and length property at FileList object where the files are also reflected at FormData object?

狂风中的少年 提交于 2019-11-25 23:42:11
问题 It is possible to set .files property of <input type=\"file\"> element to a FileList from for example a different <input type=\"file\"> element .files property or DataTransfer.files property. See Make .files settable #2866, What happens between uploading a file to an HTML form and submitting it?. FileList object has a Symbol.iterator property which we can use to set a File object which is iterable, however the .files .length is still set to 0 and passing a <form> having <input type=\"file\">

How do I download a file with Angular2

杀马特。学长 韩版系。学妹 提交于 2019-11-25 23:34:11
问题 I have a WebApi / MVC app for which I am developing an angular2 client (to replace MVC). I am having some troubles understanding how Angular saves a file. The request is ok (works fine with MVC, and we can log the data received) but I can\'t figure out how to save the downloaded data (I am mostly following the same logic as in this post). I am sure it is stupidly simple, but so far I am simply not grasping it. The code of the component function is below. I\'ve tried different alternatives,