[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):

你可能感兴趣的:(html,String,File,upload,Class,buffer)