fileapi

How to distinguish folders and files drag and drop Ajax upload in FireFox

♀尐吖头ヾ 提交于 2020-01-03 02:25:10
问题 I can not find the way to distinguish between folders and files drop in FireFox Ajax. Looks like there are no signs in FireFox FileAPI that can tell if this is a folder or a file. However I see that Google docs somehow can distinguish between folders and files drop. It does not relie on extensions or file length, files without extensions are uploaded correctly, as well as 0-lenth files are uploaded with no problem. How do I distinguish between files and folders during D&D in FF? 回答1: This

HTML5 File API modify file.name

喜你入骨 提交于 2020-01-02 05:40:11
问题 I am trying to modify a file's name if something happens. I have tried doing file.name = file.name + 'extra text'; but it doesn't work. How would I go about changing the file's name once it is uploaded? 回答1: I assume that you are using HTML5 File API to store sandboxed file to local file system. You have to get fileEntry object first if you want to modify an exist file's name: window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, function(fs){ fs.root.getFile("targetFileFullName",{}

Resumable.js: Persist file uploading between redirects and browser restarts

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 19:44:27
问题 Is it possible to make file uploads resumable after page redirect / browser restart through Resumable.js or any other Javascript API? (I seriously miss NPAPI here) 来源: https://stackoverflow.com/questions/34131621/resumable-js-persist-file-uploading-between-redirects-and-browser-restarts

Websocket File upload speed issue (Java websocket API and Javascript)

隐身守侯 提交于 2020-01-01 16:58:27
问题 I barely made websocket file upload function. But uploading speed seems to be slow. I have used Java API for websocket Server and javascript for client. Server: package websocket; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import javax.websocket.CloseReason; import javax.websocket.EndpointConfig; import javax.websocket.OnClose; import javax.websocket.OnError; import javax.websocket

What are the details can be obtained from webkitStorageInfo.queryUsageAndQuota()

耗尽温柔 提交于 2019-12-31 02:12:13
问题 webkitStorageInfo.queryUsageAndQuota() is used to find out the usage stats of the files that have been stored in the file system using the HTML5 file system API I suppose. Can anyone give me the details that can be obtained in the callback provided to this function. window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.PERSISTENT, function() { //what all details can be obtained in this function as its arguments? }) 回答1: Replace function(){...} with console.log.bind(console) , and you

Using HTML 5 File API to load a JSON file

时间秒杀一切 提交于 2019-12-30 23:24:04
问题 I want the user to be be able to chose a JSON file on there computer, this JSON file should then be made available to the client side Javascript. How would I do this using the FILE API, the ultimate goal is the the user selected JSON file to be available as an object which I can then play about with in Javascript. This is what I have so far: JsonObj = null function handleFileSelect(evt) { var files = evt.target.files; // FileList object f = files[0]; var reader = new FileReader(); // Closure

Add a File (JS object) to input type=“file”

徘徊边缘 提交于 2019-12-29 09:26:10
问题 I need a way to add a File object to a file input field. Note that I do not want to set the value of the file field. (which is a security risk, ... I know that) I already have the file itself (and all its contents!) I'm creating the File object like this: canvas.toBlob(function(blob) { var file = new File([blob], 'file.png'); // and now I want to add MY File to the input here }); Please don't tell me about how to upload the File, I know about XMLHttpRequest Level 2. I want to upload the File

“undefined” returned when accessing some listed properties of File object

只愿长相守 提交于 2019-12-29 04:26:09
问题 I can't seem to access the width or height keys of my object. I'm using dropzone.js which has an event for addedFile which returns the file and the first param. so: var myDropzone = new Dropzone('#dropzone', {url: '/'}); myDropzone.on('addedFile', function(file) { console.log(file); }); The callback works just fine, in my console I see: As you can see, there's clearly the height & width keys available. myDropzone.on('addedFile', function(file) { console.log(file.name); // returns the whole

Creating a file from a blob

家住魔仙堡 提交于 2019-12-28 06:51:09
问题 I'm in need of some javascript guru. I have this code: handleImage(new File([blob], blob.name, {type: blob.type})).done(/* something */) and handleImage = function (image) { // create some fake form data var formData = new FormData(); formData.append("attachment", image); formData.append("auto", true); formData.append("_csrf", "xxxxxxxxx"); // post to the server. return $.ajax({ url: "/some/url", data: formData, cache: false, contentType: false, processData: false, type: 'POST', error:

IE and local file reading

本小妞迷上赌 提交于 2019-12-28 06:13:30
问题 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? 回答1: 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