Giter Club home page Giter Club logo

filetodatauri's Introduction

FileToDataURI

EDIT: FileReader should now be safe to use instead of involving Flash.

A cross-browser solution to read a local file and provide the base64 encoded content with Flash.
See the example to know how to use it.
The example provides a polyfill-like solution (based on this swf file and on the FileReader API when available).

You'll need to define in your JavaScript the below code:

var Flash = {
  getFileData: function(base64) {
    /* this function is mandatory to deal with the base64 for the Flash version (old browser) */
  },
  getButtonLabel: function() {
    return "Load your file";
    /* you can use this function if you want to customize the button label for the Flash version (old browser) */
  }
};

Customization

  1. Do the changes you need in the mxml file (Flex);
  2. Download the Flex SDK;
  3. Unzip and open a console;
  4. Run the following command:
$ ./bin/mxmlc FileToDataURI.mxml

You'll have some warning messages as below:

Chargement du fichier de configuration D:\flex_sdk_4.6\frameworks\flex-config.xml
RSL requis :
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/framework_4.6.0.23201.swz avec 1 basculement.
http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz avec 1 basculement.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/spark_4.6.0.23201.swz avec 1 basculement.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/sparkskins_4.6.0.23201.swz avec 1 basculement.
http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/mx_4.6.0.23201.swz avec 1 basculement.

But it will work and you'll find the FileToDataURI.swf file in your working directory.

Inspiration

Thanks to Country/FileToDataURI for giving me the inspiration !

Note

For the first run, it's going to be a bit long to load the swf file. Actually the browser will connect to Adobe to download the swz files above. It's doing it just once, then no more download.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.