aymkdn / filetodatauri Goto Github PK
View Code? Open in Web Editor NEWA cross-browser solution to read a local file and provide the base64 encoded content
Home Page: http://aymkdn.github.com/FileToDataURI/
License: MIT License
A cross-browser solution to read a local file and provide the base64 encoded content
Home Page: http://aymkdn.github.com/FileToDataURI/
License: MIT License
hello!
How can I get the file name after the file has been readed?
thanks!
Hi, is there a way to get file attributes like file size, file name and file type?
Thank you very much for the simple solution. I am able to get the file stream (encoded data). But, I am failed to get the name of the file uploading. Is there any way we can get the file name as well? This is important that when uploading the file, on the server I should keep the same name as uploaded.
thanks
Love this but can't use it due to the GitHub default license.
Would be awesome if you could provide some neat license ๐
Hi, I have one question and one request.
I'm using FiletToDataURL.mxml to develop the commercial software, which uploads users' files website. However, I found the statement, "CC BY-NC-SA 3.0" in FiletToDataURL.mxml
Thanks,
usitaka
Thanks you for this solution , I need to use it to support older browser , I tried the code from your example page , but the problem is that the button text is "Charger Fichier" ,and once I click on it no thing is happened ( the getFileData from the java script is not fired ).
your help will be appreciated.
On my quest to upload base64 encoded image files in ie8&9 I came across your script. Looks promising but I'm having on issue.
I copy and pasted your example code, downloaded FileToDataURI.swf from the repo, downloaded expressInstall.swf and swfobject.js from the google link you provided, and updated the link to all three in the example code.
Everything works fine for browsers with FileReader but when it fallsback to flash there is an issue. The flash object is loaded and put on the page. But it seems like the Flash settings are not being used. The button is in german and after selecting a file nothing happens. Any ideas?
Here's my code
var Flash = {
/* Flash.getFileData() is called after the file has been read */
getFileData: function(base64) {
console.log(base64);
showResult(base64)
},
/* getButtonLabel() permits to define another label for the "Load a file" button in the Flash version */
getButtonLabel: function() {
return "Load a file";
}
};
// we just want to show the result into the div
function showResult(b) {
$('#file-result').text(b)
}
// check if the FileReader API exists... if not then load the Flash object
if (typeof FileReader !== "function")
// we use 80px by 23px, because we want the object to have the same size than the button
swfobject.embedSWF("/js/FileToDataURI.swf", "file-object", "120px", "50px", "10", "/js/expressInstall.swf", {}, {}, {});
else {
// replace the <object> by an input file
$('#file-object').replaceWith('<input type="file" id="file-object" value="Load a file" />');
$('#file-object').on('change', function(e) {
var files = e.target.files,file;
if (!files || files.length == 0) return;
file = files[0];
var fileReader = new FileReader();
fileReader.onload = function (e) {
// ATTENTION: to have the same result than the Flash object we need to split
// our result to keep only the Base64 part
showResult(e.target.result.split(",")[1]);
// showResult(e.target.result);
$('#file-result').append('<img src="' + e.target.result + '" />');
};
fileReader.readAsDataURL(file);
});
}
var Flash = {
/* Flash.getFileData() is called after the file has been read /
getFileData: function(base64) {
showResult(base64)
},
/ getButtonLabel() permits to define another label for the "Load a file" button in the Flash version */
getButtonLabel: function() {
return "Load a file";
}
};
function showResult(b) {
$('#file-result').text(b)
}
unable to get binary data on showresult function
below reference added to code:
swfobject.embedSWF("../Content/FileToDataURI.swf", "file-object", "200px", "90px", "10", "../Content/expressInstall.swf", {}, {}, {});//}
and below 3 files are refereed;
Content/FileToDataURI.swf
../Content/expressInstall.swf
../Scripts/swfobject.js" refered as javascript link in page
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.