fileapi

IE and local file reading

谁说胖子不能爱 提交于 2019-11-27 22:31:04
I've just watched the mozilla File API file reading as new FileReader(); etc. and I must ask is there something like that for IE? Yes, you can use ActiveX' FileSystemObject . However, an confirmation box is shown to the user everytime he runs the code. Some users might not trust you and could choose not to run the ActiveX control. Also, please note that some users also use non-IE browsers which don't support FileReader (Safari, older versions of Firefox and so on). By adding ActiveX, you still won't have 100% support for file-related APIs. Internet Explorer 10 also supports the FileReader :

Fallback for FormData in IE 8/9

被刻印的时光 ゝ 提交于 2019-11-27 20:02:53
FormData does not exist in IE 8/9 but I need that functionality in those browsers. Is there a nice fallback for this? I would try to send over json data, but I need to pass over a file to the server. I append this file to the formData in modern browsers and just submit an XHR request. Because FormData does not exist in IE 8/9 this obviously fails. // I cant seem to get this to work with a file. $.ajax({ url: '/genericHandlers/UploadDocsFile.ashx', type: "POST", data: model.toJSON(), contentType: 'application/json' }).done(function (data) { log('stuff happened!'); }); Maybe an alternative is to

How do I generate a thumbnail client-side in a modern browser?

天涯浪子 提交于 2019-11-27 19:10:07
I'm looking for an elegant way to generate a thumbnail for use with the FileAPI . Currently I get a DataURL representing an image. Problem is, if the image is very large, than moving it around and rerendering it becomes CPU intensive. I can see 2 options to get around this. Generate a thumbnail on the client Generate a thumbnail on the server, send the thumbnail back to the client (AJAX). With HTML5 we have a canvas element? Does anyone know how to use it to generate thumbnails from pictures? They don't have to be perfect -- sampling quality is acceptable. Is there a jQuery plugin that will do

restrict file upload selection to specific types

一个人想着一个人 提交于 2019-11-27 13:00:54
Anyway to restrict the selection of file types via the <input type="file" /> element? For instance, if I wanted only images types to be uploaded, I would restrict the possible selections to (image/jpg,image/gif,image/png), and the selection dialog would grey out files of other mime types. p.s. I know that I can do this after the fact with the File API by scanning the .type attributes. I'm really trying to restrict this before hand.. I also know I can do this via flash, but I do NOT want to have use flash for this. amosrivera There is an html attribute for this specific purpose called accept

Reading multiple files with Javascript FileReader API one at a time

懵懂的女人 提交于 2019-11-27 12:16:26
问题 I'm using the FileReader API to read multiple files. <html> <body> <input type="file" id="filesx" name="filesx[]" onchange="readmultifiles(this.files)" multiple=""/> <div id="bag"><ul/></div> <script> window.onload = function() { if (typeof window.FileReader !== 'function') { alert("The file API isn't supported on this browser yet."); } } function readmultifiles(files) { var ul = document.querySelector("#bag>ul"); while (ul.hasChildNodes()) { ul.removeChild(ul.firstChild); } function setup

Get filename after filereader asynchronously loaded a file

梦想的初衷 提交于 2019-11-27 12:02:31
问题 i am loading several files in a directory to parse some data from them. This works great so far, but i would like to know wich file i am looking at. So i need the name of the file after it was loaded. Can anybody help on that? // gets all files in dir function updateData(){ var dirReader = approot.createReader(); var fail =failCB('Error - Directory for parsing failed to open'); // logs fail... dirReader.readEntries(parseData,fail); } // loading each file function parseData(entries){ var i;

How to create File object from Blob?

你。 提交于 2019-11-27 11:57:11
问题 DataTransferItemList.add allows you to override copy operation in javascript. It, however, only accepts File object. Copy event The code in my copy event: var items = (event.clipboardData || event.originalEvent.clipboardData); var files = items.items || items.files; if(files) { var blob = Blob.fromDataURL(_this.editor.selection.getSelectedImage().toDataURL("image/png")); files.add(blob); } The error in chrome: Uncaught TypeError: Failed to execute add on DataTransferItemList : parameter 1 is

Large file upload with WebSocket

旧时模样 提交于 2019-11-27 11:23:08
I'm trying to upload large files (at least 500MB, preferably up to a few GB) using the WebSocket API. The problem is that I can't figure out how to write "send this slice of the file, release the resources used then repeat". I was hoping I could avoid using something like Flash/Silverlight for this. Currently, I'm working with something along the lines of: function FileSlicer(file) { // randomly picked 1MB slices, // I don't think this size is important for this experiment this.sliceSize = 1024*1024; this.slices = Math.ceil(file.size / this.sliceSize); this.currentSlice = 0; this.getNextSlice

HTML5 File API downloading file from server and saving it in sandbox

孤者浪人 提交于 2019-11-27 10:16:52
I'm trying to understand HTML5 API. I'm designing the web application where the browser client need to download multiple files from server; user will perform something with the downloaded files and the application than need to save the state on user hard-rive. I understand that the browser can save these files only to its sandbox which is fine as long as the user can retrieve those files on the second time he starts the application. Should I use BlobBuilder or FileSaver? I'm a bit lost here. mayconbordin I'm going to show you how to download files with the XMLHttpRequest Level 2 and save them

Chrome memory issue - File API + AngularJS

∥☆過路亽.° 提交于 2019-11-27 07:38:05
问题 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