Created
June 9, 2020 09:57
-
-
Save kabeer11000/234bba56d529a272ec4ec8382d725a59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------JAVASCRIPT EXAMPLE--------// | |
/* MAIN FUNCTION TO UPLOAD STRING AS TEXT FILE TO SERVER */ | |
function UploadFile(data, folderid) | |
{ | |
var formData = new FormData(); | |
//File Mime Type | |
var blob = new Blob([data], { type: 'plain/text' }); | |
//*IMPORTANT*. Kabeers Drive will only accept if paramenter name is 'file[]' (Array) | |
formData.append('file[]', blob,'temp.txt'); | |
var request = new XMLHttpRequest(); | |
request.open('POST', "http://drive.hosted-kabeersnetwork.unaux.com/server/api/upload/index.php?id=" + folderid); | |
request.send(formData); | |
request.onreadystatechange = function (){ | |
if (request.readyState == 4 && request.status == 200){ | |
console.log("File uploaded!"+ this.response); | |
} | |
} | |
} | |
var userid = auth(); | |
var text = 'Hello World'; | |
//UserID is same as users "My Drive (Root)" folder Id | |
UploadFile(text, userid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment