[Quixote]上传时错误TypeError: coercing to Unicode: need string or buffer, htmltext found

#保存接收到的图片
class Save(Directory):
    _q_exports = ['']
   
    def _q_index[html](self):
        max_size = 10485760
        if True:#get_user():
            upload = get_field('file')

            pos = upload.fp.tell()  # Save current position in file.
            upload.fp.seek(0, 2)    # Go to end of file.
            size = upload.fp.tell() # Get new position (which is the file size).
            upload.fp.seek(pos, 0)  # Return to previous position.
            upload.size = size
            if size > max_size:
                msg = "The uploaded file is too big (size=%s, max=%s bytes)"
                msg %= (size, max_size)
                raise QueryError(msg)

            out = open('/usr/me/2.jpg', 'w')
            # Copy file in chunks to avoid using lots of memory.
            while 1:
               chunk = upload.read(1024 * 1024)
               if not chunk:
                   break
               out.write(chunk)
            out.close()
            upload.close()

 

将红色行中的[html]去掉,变成->def _q_index(self):

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值