fileapi

Create multiple input type=“file” elements with their corresponding value (FileList) according to the main input type=“file” (multiple) element

痴心易碎 提交于 2019-11-28 14:23:50
I have this code where I loop unto files from a multiple input file type $(function(){ $('#main-input').change(function(){ var files = $('#main-input')[0].files; for (var i = 0, f; f = files[i]; i++) { alert(files[i].name); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="file" id="main-input" multiple> What I'm trying to achieve, is clone the main input (#main-input) and gives a value (file) base on the loop files. Any ideas, suggestions please? or is this even possible? Yes, the requirement is possible. You will need to create a

Chrome memory issue - File API + AngularJS

混江龙づ霸主 提交于 2019-11-28 13:23:11
I have a web app that needs to upload large files to Azure BLOB storage. My solution uses HTML5 File API to slice into chunks which are then put as blob blocks, the IDs of the blocks are stored in an array and then the blocks are committed as a blob. The solution works fine in IE. On 64 bit Chrome I have successfully uploaded 4Gb files but see very heavy memory usage (2Gb+). On 32 bit Chrome the specific chrome process will get to around 500-550Mb and then crash. I can't see any obvious memory leaks or things I can change to help garbage collection. I store the block IDs in an array so

Instantiate File object in Microsoft Edge

一个人想着一个人 提交于 2019-11-28 11:26:00
I'm trying to create an image file from a blob-object using the File API and then add it to a form to be sent via XHR. Works like a charm in chrome, but crashes the app in Microsoft Edge. let file = new File([blobContent], "image.png"); let form = new FormData(); form.append("file", file); Are there any alternatives to the File API or workarounds to attach a file to the form? If I just add the blob to the form it's not recognized as an image. Thanks! Currently IE11, and Edge support the FileAPI but not the File constructor. In the link that you posted to caniuse.com , there are notes for IE

file input size issue in safari for multiple file selection

杀马特。学长 韩版系。学妹 提交于 2019-11-28 10:02:32
I am experiencing inconsistencies with regard to multiple file upload in Safari 5.1 on Windows Vista (haven't tried other platforms). The input element has the multiple flag to allow selection of multiple files. The problem occurs when the user does actually select more then one file. In this case, each File has a size attribute of 0 . If (still with the multiple flag), the user only chooses one file, the size attribute correctly contains the file size. The problem can be seen in the following example. Test and view the output of both a single file selection and a multiple file selection. (You

encode/decode image with base64 breaks image

大城市里の小女人 提交于 2019-11-28 07:47:24
I am trying to encode and decode an image. I am using the FileReader's readAsDataURL method to convert the image to base64. Then to convert it back I have tried using readAsBinaryString() and atob() with no luck. Is there another way to persist images without base64 encoding them? readAsBinaryString() Starts reading the contents of the specified Blob, which may be a File. When the read operation is finished, the readyState will become DONE, and the onloadend callback, if any, will be called. At that time, the result attribute contains the raw binary data from the file. Any idea what I'm doing

Select & Drop Files and/or Folders to be parsed

守給你的承諾、 提交于 2019-11-28 02:22:22
问题 I've used a part from a post here on SO ( I can't remember it though ) to parse files and folders on Chrome, but I cannot get it to work on Firefox (and to be honest I haven't tried it on others, though I think it doesn't work on safari either). Here's the 2 directives, ngDrop and input. angular.module('myApp').directive("ngDrop", function($rootScope) { var link = function($scope, elements, attr, ngModel) { var parseInput = function(event) { var list = []; $scope.count = 0; var toParse = [];

How to create an ArrayBuffer and data URI from Blob and File objects without FileReader?

◇◆丶佛笑我妖孽 提交于 2019-11-28 01:51:18
This Question is related to and inspired by How to updoad in old browsers (ex Safari 5.1.4) Given an <input type="file"> element having a files property containing File objects which inherit from Blob , is it possible to create a ArrayBuffer and convert the ArrayBuffer to a data URI from a Blob or File object without using FileReader ? Approaches have tried so far have been create a mock WebSocket with .binaryType set to "arraybuffer" , create a MessageEvent with event.data set to File object; result is File object at onmessage handler set prototype of File to ArrayBuffer , Uint8Array ; result

How to read files from folder

隐身守侯 提交于 2019-11-28 01:38:23
问题 Found this article which showing how to distinguish file upload from directory How to handle dropped folders but they not explain how I can handle the directory upload. Having difficulties to find any example. Anyone know how to get File instance of each file in directory? Copied from that article: <div id=”dropzone”></div> var dropzone = document.getElementById('dropzone'); dropzone.ondrop = function(e) { var length = e.dataTransfer.items.length; for (var i = 0; i < length; i++) { var entry

Read a local file using JavaScript HTML5 file api (offline website)

二次信任 提交于 2019-11-28 01:22:48
I am working on an web site which will be packed in an .exe file. So the site will only be used offline. Now i need to parse an local xml document. How can i get the file handle to a local file using html5 file api? EDIT: I dont want to use <input...> or dragging file into browser. I'm afraid I may be the bearer of bad news for your design: The action you are requesting expressly violates the security model as specified in the File API spec. The client implementation of FileReader() must make sure that "all files that are being read by FileReader objects have first been selected by the user."

JS and type.match as file mime type - need advice

让人想犯罪 __ 提交于 2019-11-28 00:22:41
问题 Today I faced an interesting thing as FF File API and separate files by their types. OK here is a little snippet as if (!input.files[0].type.match('image.*')) { window.alert("Select image please"); return; } it controls image being read only. But what about doc files and pdf for example? I couldn't find useful examples for this thing so I hope you can share some snippets. The thing I am interested in detecting different file types but how can I control different file types with JS and its