Here is a little demo of a uploader what works in AMS, this is AMS+Nginx/PHP(lua/html(css)/js) based using the IE element with IE 11 enabled
The uploading script that accepts the file is super easy
This is apart of another app so some parts of the code might look like they do nothing but they do they send or set options for later use.

Video Demo
AMS
On Navigate
On Loaded
upload.php
Basic HTML template with JS
The uploading script that accepts the file is super easy
This is apart of another app so some parts of the code might look like they do nothing but they do they send or set options for later use.
Video Demo
AMS
On Navigate
PHP Code:
Web.Stop("Web1")
_Do = false
if e_URL ~= nil then
if String.Find(e_URL, "#success||", 1, true) ~= -1 then
__FileFileName = DelimitedStringToTable(e_URL, "||");
__ClosedURL = String.Replace(e_URL, "__Tools/__Upload/#success||"..__FileFileName[2], "__Share/"..__FileFileName[2]);
Label.SetText("Error_Text", "Upload Completed");
Web.SetEnabled("Web1", false);
__ExitThis = false;
_Do = false;
if _CloseBox then
__ExitThis = true;
_Do = true;
else
__ExitThis = false
_Do = false;
end
end
if String.Find(e_URL, "#error||", 1, true) ~= -1 then
__ShowErrors = DelimitedStringToTable(e_URL, "||");
__ErrorMSG = "An unknown error as been commited";
if __ShowErrors[2] == "overmaxsize" then
Label.SetText("Error_Text", "File to big");
end
if __ShowErrors[2] == "nofile" then
Label.SetText("Error_Text", "No file detected");
end
if __ShowErrors[2] == "unknown" then
Label.SetText("Error_Text", "Unknown Error");
end
__ExitThis = false
_Do = true;
end
end
PHP Code:
if _Do then
Web.LoadURL("Web1", "{URLROOT}__Tools/__Upload_1/");
_Do = false;
if __ExitThis then
DialogEx.Close();
end
end
PHP Code:
<?php
if ($_FILES["file1"]["size"] >= 1073741824){
echo "#error||overmaxsize";
exit();
}
if (!$_FILES["file1"]["tmp_name"]) {
echo "#error||nofile";
exit();
}
if(move_uploaded_file($_FILES["file1"]["tmp_name"] , "../../__Share/".$_FILES["file1"]["name"])){
echo "#success||".$_FILES["file1"]["name"];
} else {
echo "#error||unknown";
}
?>
PHP Code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css">
<script>
function _(el){
return document.getElementById(el);
}
function uploadFile(){
_("progress-box").style.display = "block";
var file = _("file1").files[0];
var formdata = new FormData();
if (file.size >= 1073741824){
_("progress-bar").style.backgroundColor = "#d60a1f";
window.location.href = './#error||overmaxsize';
}else{
formdata.append("file1", file);
_("file1").style.display = "none";
_("file2").style.display = "none";
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "upload.php");
ajax.send(formdata);
}
}
function progressHandler(event){
var percent = (event.loaded / event.total) * 100;
_("progress-bar").style.width = Math.round(percent)+"%";
}
function completeHandler(event){
_("progress-bar").style.backgroundColor = "#2a922e";
window.location.href = './'+event.target.responseText;
}
function errorHandler(event){
}
function abortHandler(event){
}
</script>
</head>
<body>
<form id="upload_form" enctype="multipart/form-data" method="post">
<div id="progress-box" class="progress" style="display:none;">
<div id="progress-bar" class="progress-bar" style="width:0%; background-color: rgb(121, 8, 140);"></div>
</div>
<input type="file" name="file1" id="file1" /><input id="file2" type="button" value="Upload File" onclick="uploadFile()" />
<h3 id="status"></h3>
<p id="loaded_n_total"></p>
</form>
</body>
</html>
Comment