我正在将文件复制到临时目录
/opt/vtiger/config/config.inc.php
并希望在我上传后将其删除
def uploadAvatar(self, schid, img):
try:
img = path.abspath(img)
filename = self.generateAvatarFileName(schid)
temp_dir = tempfile.gettempdir()
self.tmp = path.join(temp_dir, filename)
copy2(img, self.tmp)
#imgname = path.basename(self.tmp)
imgdir = path.dirname(self.tmp)+path.sep
self.retcode = ts3lib.createReturnCode()
(error, ftid) = ts3lib.sendFile(schid, 0, "", "/avatar/"+filename, True, False, imgdir, self.retcode);
except:
try: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon Script", 0)
except:
try: from traceback import format_exc;print(format_exc())
except: print("Unknown Error")
但我总是得到
def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage):
if self.retcode == returnCode: self.setAvatar(schid, self.tmp);remove(self.tmp)
怎么能做到这一点?请帮忙!
答案 0 :(得分:2)