From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojo/tests/io/upload.cgi | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 includes/js/dojo/tests/io/upload.cgi (limited to 'includes/js/dojo/tests/io/upload.cgi') diff --git a/includes/js/dojo/tests/io/upload.cgi b/includes/js/dojo/tests/io/upload.cgi new file mode 100644 index 0000000..a13656f --- /dev/null +++ b/includes/js/dojo/tests/io/upload.cgi @@ -0,0 +1,60 @@ +#!/usr/bin/python + +# FROM: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/273844 + +import cgi +import cgitb; cgitb.enable() +import os, sys +import string + +UPLOAD_DIR = "/tmp/upload/" +form = cgi.FieldStorage() + +dbg = [] + +def debug(dbgstr): + dbg.append(str(dbgstr)) + +def save_uploaded_file(form_field, upload_dir): + global form + if not form.has_key(form_field): + debug("didn't find it! (1)") + return + fileitem = form[form_field] + if not fileitem.file: + debug(form.getvalue(form_field, "")) + debug(fileitem.__dict__) + debug("didn't find it! (2)") + return + fout = file(os.path.join(upload_dir, fileitem.filename), 'wb') + while 1: + chunk = fileitem.file.read(100000) + if not chunk: break + fout.write (chunk) + fout.close() + +retval = "false"; +fileFields = "" + +if form.has_key("fileFields"): + fval = str(form.getvalue("fileFields", "")) + fileFields = fval.split(",") + debug("'fileCount': '" + str(len(fileFields)) + "',") + for field in fileFields: + debug("'fileField' : '"+field + "',") + save_uploaded_file(str(field).strip(), UPLOAD_DIR) + retval = "true"; + +debug("'retval': " + retval) + +print """Content-Type: text/html + + + + + + + + + +""" % (string.join(dbg, "\n")) -- cgit v1.2.3