cgi获取提交的图像数据 - 网址

时间:2013-03-27 06:06:47

标签: python google-app-engine cgi

对不起,如果这个问题很愚蠢。我将jqplot图像转换为data-url并使用表单发送。在新页面中,我使用cgi.FieldStorage()来获取提交的数据网址,但什么也没得到。那么有人能给我一些关于我的方法的建议吗?谢谢!

我在Google App Engine上使用Python

输入页面Javascript

var imgData = $('#chart1').jqplotToImageStr({});
$('<tr style="display:none"><td><input type="hidden" name="extract1"></td></tr>')
    .appendTo('.getpdf')
    .find('input')
    .data(imgData);

输出页面:

def post(self):
    form = cgi.FieldStorage()   
    extract1 = form.getvalue('extract1') #extract1 is empty

我尝试打印表单,它看起来像:MiniFieldStorage('extract1', '"data:image/png;base64,iVBORw0KGgoAAAANSUhE

如果我分配了data-url(data:image / png; base64,iVBORw0KGg ...),那就可以了。

1 个答案:

答案 0 :(得分:1)

我有(工作)代码做类似的事情。

def post(self):
  img_data = self.request.get('extract1')
  # then strip off the prefix and convert from base64

是我正在做的事情。追加cgi.FieldStorage并不是我通常在Python App Engine应用程序中看到的。