summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/image.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/js/image.js b/js/image.js
index 1fd91ff..7a5240f 100644
--- a/js/image.js
+++ b/js/image.js
@@ -45,18 +45,12 @@ function decimalString(n){
}
function noop(){}
-// http://www.carbonpictures.com/bucky/data/2835/photoblaster_safe_upload.cgi.txt
function uploadImage(opt){
if (! opt.blob || ! opt.filename) return;
opt.username = opt.username || "";
opt.success = opt.success || noop;
opt.error = opt.error || noop;
-
- // FormData params >>
- // qqfile .. file data .. or comes in with postdata
- // filename .. filename
- // username .. nick
var form = new FormData();
@@ -68,9 +62,15 @@ function uploadImage(opt){
req.open("POST", "/cgi-bin/im/upload");
req.onload = function(event) {
if (req.status == 200) {
- opt.success(req.responseText);
+ var res = JSON.parse(req.responseText);
+ if (res.success) {
+ opt.success(res);
+ }
+ else {
+ opt.error(res);
+ }
} else {
- opt.error(req.responseText);
+ opt.error({ success: false, error: req.status });
}
};
req.send(form);