Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.06 KB

README.md

File metadata and controls

42 lines (33 loc) · 1.06 KB

ZeroBit Browser Example

Upload File Directly from Browser

zerobit

Simply upload a file through a form input. Wait, then the URL and hash will be displayed in a blue box. To see it in action, simply open the index.html file in your browser.

Code

Full Code in folder

$(".upload-btn").on("click", function (e) {
    // Get form data
    var data = new FormData($(".upload")[0]);

    // Create URL
    var url = BASE_PATH + ACCESS_TOKEN_PARAM

    // Request Body
    var uploadSettings = { 
      "url": url, 
      "data": data, 
      "cache": false, 
      "async": true, 
      "processData": false, 
      "contentType": false, 
      "crossDomain": true, 
      "method": 
      "POST", 
      "mimeType": "multipart/form-data"
    }

    // Upload file
    $.ajax(uploadSettings).done(function (response) {
      // Get Response
      resJson = JSON.parse(response)
      // Jquery styling
      console.log(resJson)
    });