fileapi

Disable File drag & drop if there isn't a file input

倖福魔咒の 提交于 2019-12-04 06:38:52
I think the solution to this is staring me in the face, but I can't seem to find it. So, I'm making a site that has a small file upload section. The upload section will have a place to upload an image for different devices and device orientations (i.e. iPhone, iPad, portrait and landscape). I can easily figure out how to implement the drag & drop on the individual device icons, but if the user misses the drop area, the browser will just navigate to that image on their system. How do I disable drag & drop if there isn't a file input type to receive the dragged file? This document (documentation

Understanding Object URLS for client-side files and how to free the memory

佐手、 提交于 2019-12-03 15:11:50
I am using createObjectURL to get a reference URL to a local image file. When I am done with the file/image, I call revokeObjectURL to free that memory. Everything works fine for me but I just want to be sure that I am releasing all the memory I can. My concern arose after I inspected the chrome://blob-internals page. Upon calling createObjectURL and using the image, I noticed two entries were created. One with url blob:blobinternal:///d17c4eef-28e7-42bd-bafa-78d5cb86e761 and the other blob:http://localhost/dbfe7b09-81b1-48a4-87cd-d579b96adaf8 Both referred to the same local file path though.

Using FileReader.readAsArrayBuffer() on changed files in Firefox

别说谁变了你拦得住时间么 提交于 2019-12-03 11:21:18
问题 I'm running into an odd problem using FileReader.readAsArrayBuffer that only seems to affect Firefox (I tested in the current version - v40). I can't tell if I'm just doing something wrong or if this is a Firefox bug. I have some JavaScript that uses readAsArrayBuffer to read a file specified in an <input> field. Under normal circumstances, everything works correctly. However, if the user modifies the file after selecting it in the <input> field, readAsArrayBuffer can get very confused. The

File manipulations such as Read/Write local files using Javascript without server

两盒软妹~` 提交于 2019-12-03 09:01:17
I'm just trying on the task, file manipulation system using java script. As I was referred from W3C File API( https://www.w3.org/TR/FileAPI/ ), we can only read local files like var file = "test.txt"; function readTextFile(file) { var readFile; if(window.XMLHttpRequest){ // for new browsers readFile = new XMLHttpRequest(); }else{ //for old browsers like IE5 or IE6 readFile = new ActiveXObject("Microsoft.XMLHTTP"); } readFile.open("GET", file, true); readFile.onreadystatechange = function() { if(readFile.readyState === 4) { if(readFile.status === 200 || readFile.status == 0) { //text will be

window.URL.revokeObjectURL() doesn't release memory immediately (or not at all)?

时光怂恿深爱的人放手 提交于 2019-12-03 08:14:11
问题 I'm making an html interface to upload images on a server with Drag & Drop and multiple selection files. I want to display the pictures before sending them to the server. So I first try to use FileReader but I have had some problems like in this post. so I change my way and I decided to use blob:url like ebidel recommands in the post, with window.URL.createObjectURL() and window.URL.revokeObjectURL() to release memory. But now, I've got another problem, wich is similar to this one. I want

How to write UTF-8 or Base64 data into a file (jpg/doc/pdf) on local storage(sdcard) in Phonegap

寵の児 提交于 2019-12-03 07:30:39
I am getting byte array like var byteArr=[12,-123,43,99, ...] from API, Then I am converting it into UTF-8 String by var utf8_str = String.fromCharCode.apply([], new Uint8Array(byteArr)); Then converting UTF-8 string to Base64 string by var base64_str= window.btoa(utf8_str); Now I am writing UTF-8 or Base64 string to file (xyz.pdf/xyz.jpg) by FileWriter in Phonegap, but it show me blank file when open it. function gotWriteFile(dirEntry) { dirEntry.getFile(FILE_NAME, {create: true, exclusive: false}, gotFileWriteEntry, failWrite); } function gotFileWriteEntry(fileEntry) { fileEntry.createWriter

jquery.support to detect JavaScript's File API?

时光怂恿深爱的人放手 提交于 2019-12-03 05:55:14
I can't find the way to detect if the browser supports the File API through the .support methon in jQuery. Anyone knows it? (Incidentally: a way to detect the size of a file in input[type=file] with IE?) It does not seem to be implementd in jQuery, but you could check yourself: http://jsfiddle.net/pimvdb/RCz3s/ . The files property of an <input type='file'> returns an empty FileList if it's implemented, and otherwise it is not defined (i.e. it is undefined ). var support = (function(undefined) { return $("<input type='file'>") // create test element .get(0) // get native element .files !==

Using FileReader.readAsArrayBuffer() on changed files in Firefox

六眼飞鱼酱① 提交于 2019-12-03 02:49:48
I'm running into an odd problem using FileReader.readAsArrayBuffer that only seems to affect Firefox (I tested in the current version - v40). I can't tell if I'm just doing something wrong or if this is a Firefox bug. I have some JavaScript that uses readAsArrayBuffer to read a file specified in an <input> field. Under normal circumstances, everything works correctly. However, if the user modifies the file after selecting it in the <input> field, readAsArrayBuffer can get very confused. The ArrayBuffer I get back from readAsArrayBuffer always has the length that the file was originally. If the

How to Create a New Folder for Downloading a File

99封情书 提交于 2019-12-02 00:41:55
问题 I want to download folder that client side (browser) make. I considered using File API, but I can't find how to make folder. For example, some png make from html canvas put one folder, I want to save this folder with download dialog. I want to use a folder for some file to one folder.and I must download only once. Please advise me. html <a download='folder' href='#' onclick="Download()">download</a> 回答1: You can use FSO.js, but be warned that it currently only works in Chrome. Additionally,

Copying a file using Cordova

懵懂的女人 提交于 2019-12-01 23:34:22
问题 I've been trying to copy file named versions.txt from applicationDirectory to externalApplicationStorageDirectory using cordova but code fails. here is the code var path = cordova.file.applicationDirectory + "www/Data/versions.txt"; window.resolveLocalFileSystemURL(path, function gotFile(fileEntry) { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function onSuccess(fileSystem) { var directory = new DirectoryEntry("versions.txt", path); fileEntry.copyTo(directory, 'versions.txt',