Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.73 KB

README.md

File metadata and controls

64 lines (47 loc) · 1.73 KB

js-upload-class

Frontend handle using info pulled from backend or frontend.


How to use

<script type="text/javascript" src="functions.js"></script>
<link rel="stylesheet" href="style.css" />

And add the input tag on you page:

<input type="file" name="image" />

  • For FrontEnd Only: Maybe you just want to work on frontend or use indexedDB in your application, and you need to handle uploads. Well, you can do it with the following (assuming you already have any profile of any sort):
    const build = () => {
    
      var x = {
        config: {
          types: ["*"],
          total: 1,
          integrity: "none",
          size: 10000000,
        }
      };
    
      setTimeout(() => {
          Upload.setOnReadCallback((result) => {
            let contents = atob(result.split(",")[1]);
            //Do your stuff
          });
          Upload.setOnUploadCallback((result,inputEl) => {
            //Do your stuff
          });
          let input = document.querySelector("[name=image]");
          Upload.build([input]);
          Upload.mount(input, x);
          Upload.middleware(input, x);
      }, 1000);
    };

The script will do whatever you tell it to while READING the file. This method is still to be improved.

The class will call the script functions and prepare the input and upload functions to you!

Enjoy!