Ejemplo n.º 1
0
 def save_my_information(self):
     inputs = web.input()
     try:
         try:
             if len(inputs['imgfile'])>10:
                 htmlimg = httpUploadedFile(inputs['imgfile'])
                 userimg=Images().create(
                     uuid =  htmlimg.uuid(),
                     description = self.htmlunquote("上传图片"),
                     thumbnail = self.wap_imgsave(htmlimg)
                     )
         except Exception, e:
             print e
             userimg=Images().get(Images.id == 1)
         
         user = Users.get(Users.id == int(inputs['userid']))
         user.name = inputs['name']
         user.cellphone = inputs['cellphone']
         user.gender = inputs['gender']
         user.email = inputs['email']
         user.job = inputs['job']
         user.avatur=userimg
         user.address = inputs['address']
         user.save()
         return self.my_information()
Ejemplo n.º 2
0
    def saveImage(self):
        inputParams = web.input()
        if inputParams.has_key('file') and not inputParams['file']:
            return self.error(msg = '未指定文件')

        f = None

        try:
            self.desc = inputParams['desc']
            self.ref = inputParams['ref'] 
            f = httpUploadedFile(inputParams.file)
            if f.mimetype() != 'image/jpeg':
                os.unlink(f.target())
                return self.error(msg='上传失败')
            self.recordImage(f)
        except Exception, e:
            if f and os.path.exists(f.target()):
                os.unlink(f.target())
            return self.error(msg='上传失败: %s' % e)
Ejemplo n.º 3
0
    def saveImageDefault(self):
        inputParams = web.input()
        if inputParams.has_key('file') and not inputParams['file']:
            return self.error(msg = '未指定文件')

        f = None
        try:
            self.desc = '默认上传图片'
            self.ref = ''

            f = httpUploadedFile(inputParams.file)
            if f.mimetype() != 'image/jpeg' and f.mimetype()=='image/png' and f.mimetype() != 'application/zip':
                os.unlink(f.target())
                return self.error(msg='上传失败')
            if f.mimetype() == 'image/jpeg' or f.mimetype()=='image/png':
                self.recordImage(f)
        except Exception, e:
            if f and os.path.exists(f.target()):
                os.unlink(f.target())
            return self.error(msg='上传失败')
Ejemplo n.º 4
0
    def saveFile(self):
        inputParams = web.input()
        if inputParams.has_key('file') and not inputParams['file']:
            return self.error(msg = '未指定文件')

        f = None

        try: 
            self.desc = inputParams['desc']
            self.ref = inputParams['ref'] if inputParams.has_key('ref') else None

            f = httpUploadedFile(inputParams.file)
            if f.mimetype().startswith('image'):
                c = self.recordImage(f)
                self.privData['text'] = self.imageUrl(c.lastrowid)
            else:
                return self.error(msg = '未知的文件类型')
        except Exception, e:
            if f and os.path.exists(f.target()):
                os.unlink(f.target())
            return self.error(msg = '保存对象失败: %s' % e)
Ejemplo n.º 5
0
    def saveImageDefault(self):
        inputParams = web.input()
        if inputParams.has_key('file') and not inputParams['file']:
            return self.error(msg = '未指定文件')

        f = None
        try:
            self.owner = 1
            self.desc = 'the image upload by default'
            self.ref = ''
            self.album = 1

            f = httpUploadedFile(inputParams.file)
            if f.mimetype() != 'image/jpeg':
                os.unlink(f.target())
                return self.error(msg='上传失败')
            if f.mimetype() == 'image/jpeg':
                self.recordImage(f)
        except Exception, e:
            if f and os.path.exists(f.target()):
                os.unlink(f.target())
            return self.error(msg='上传失败')
Ejemplo n.º 6
0
 def raise_question(self):
     inputs = web.input()
     user =Users.get(Users.name == self.isLogin())
     self.desc = '提问上传图片'
     self.ref = ''
     try:
         title = inputs['title']
         content =inputs['content']
         imgfilelst=[]
         imageslst=[]
         imgfilelst.append(inputs['imgfile1'])
         imgfilelst.append(inputs['imgfile2'])
         imgfilelst.append(inputs['imgfile3'])
         for item in imgfilelst:
             try:
                 if len(item)>10:
                     htmlimg = httpUploadedFile(item)
                     imageslst.append([htmlimg.uuid(),self.wap_imgsave(htmlimg)])
                 else:
                     imageslst.append(["default",Images().get(Images.id == 1).thumbnail])
             except Exception, e:
                 imageslst.append(["default",Images().get(Images.id == 1).thumbnail])
         
         self.privData['USER'] = user
         question = Questions.create(
             title = title,
             content = content,
             owner = user,
             uuid1=imageslst[0][0],
             uuid2=imageslst[1][0],
             uuid3=imageslst[2][0],
             img1=imageslst[0][1],
             img2=imageslst[1][1],
             img3=imageslst[2][1]
             
         )
         question.save()
         return self.questions()