Back

UploadFile

JS Py
Hello World

Uploads a file to a server.

app.UploadFile( url, file, name, callback? )

Example - Upload File

function OnStart()
{
    var name = app.GetAppName() + ".js";
    var file = app.GetAppPath() + "/" + name;
    app.UploadFile( "https://yourwebsite.com/upload", file, name, OnUpload );
}

function OnUpload( error, file, result )
{
    if(error) app.Alert( "Upload Failed!" )
    else app.ShowPopup( "Response:\n" + result, "Upload Successful!" );
}
from native import app

def OnStart():
    global file
    name = app.GetAppName() + ".js"
    file = app.GetAppPath() + "/" + name
    app.UploadFile("https://yourwebsite.com/upload", file, name, OnUpload)

def OnUpload(error, file, result):
    if error:
        app.Alert("Upload Failed!")
    else:
        app.ShowPopup("Response:\n" + result, "Upload Successful!")
Copy All       Run      
String
String: path to file ( “/absolute/...” or “relative/...” )
String: url path
function()