Permalink
Browse files

Upload Zip File Directly To Server + Button

  • Loading branch information...
1 parent 61721dc commit 35789f46bf4eff062c5aca8d679824a71e901d21 @angela-ko angela-ko committed Aug 6, 2016
Showing with 17 additions and 15 deletions.
  1. +17 −15 js/photonic3d.js
View
@@ -74,30 +74,32 @@ function makeZip() {
name = loadedFile.name;
}
uploadZip(zipFile.generate({type: 'blob'}), name + '.zip');
- $location.path('/printables');
+ window.location = "/printablesPage";
}
}
-function uploadZip(zipFile) {
- var blob = zipFile,
- form = new FormData(),
- request = new XMLHttpRequest();
- form.append("blob",blob);
- request.open(
- "POST",
- "/services/printerables//uploadPrintableFile",
- true
- );
+function uploadZip(zipFile, fileName) {
+ var blob = zipFile;
+ form = new FormData();
+ form.append("file",blob,fileName);
+ request = new XMLHttpRequest();
+ request.open("POST", "/services/printables/uploadPrintableFile");
request.send(form);
}
function makeButton() {
+ //rename original zip button
var btn = document.getElementById("zip-button");
- btn.onclick = function () {
+ btn.innerHTML = "Download Zip";
+ //create new zip button
+ var newbtn = document.createElement("BUTTON");
+ newbtn.onclick = function () {
makeZip();
- };
- btn.id = "new-zip-button";
- btn.innerHTML = "New Zip";
+ }
+ newbtn.id = "new-zip-button";
+ newbtn.className = "btn btn-primary";
+ newbtn.innerHTML = "Upload ZIP To Printables";
+ btn.parentNode.insertBefore(newbtn, btn);
}
$(document).ready(initializeValues);

0 comments on commit 35789f4

Please sign in to comment.