diff options
| author | jules <jules@okfoc.us> | 2013-12-27 12:20:01 -0500 |
|---|---|---|
| committer | jules <jules@okfoc.us> | 2013-12-27 12:20:01 -0500 |
| commit | c485642e59fc8043a68c9993976b1b7a705ac8fb (patch) | |
| tree | c26653dda389d9ebb8349a5c3341eb958c77beb7 /js/image.js | |
| parent | bd83ed70eae58e262b1f5a0a861d20e4606dad9b (diff) | |
upload button
Diffstat (limited to 'js/image.js')
| -rw-r--r-- | js/image.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/js/image.js b/js/image.js index ffb7dad..c8f3458 100644 --- a/js/image.js +++ b/js/image.js @@ -43,5 +43,37 @@ function decimalString(n){ var m = Math.floor(n); return m + "." + Math.round((n-m)*10) } +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(); + + form.append("username", opt.username); + form.append("filename", opt.filename); + form.append("qqfile", blob); + + var req = new XMLHttpRequest(); + req.open("POST", "/cgi-bin/im/upload"); + req.onload = function(event) { + if (req.status == 200) { + opt.success(req.responseText); + } else { + opt.error(req.responseText); + } + }; + req.send(form); +} |
