python 및 cherrypy의 초보자입니다. 파일 업로드 문제 - Python-WIndows-CheryyPy
@cherrypy.tools.noBodyProcess()
def POST(self,theFile=None):
lcHDRS = {}
for key, val in cherrypy.request.headers.iteritems():
lcHDRS[key.lower()] = val
formFields = myFieldStorage(fp=cherrypy.request.rfile,
headers=lcHDRS,
environ={'REQUEST_METHOD':'POST'},
keep_blank_values=True)
dt = datetime.now()
date = dt.strftime('%Y-%m-%d')
dt = dt.strftime('%Y%m%d%H%M%S')
theFile = formFields['theFile']
theFile.filename = str(dt) + "file"
shutil.copy2(theFile.file.name,os.path.join(absolutePath , theFile.filename))
...
...
내가 경로 os.path.join (absolutePath, theFile.filename)를 확인하고 적절한오고있다 : 나는 다음과 같은 코드를 사용하여 파일을 업로드하는 것을 시도하고있다. 문제는 코드가 Linux 우분투에서는 제대로 작동하지만 Windows에서는 제대로 작동하지 않는다는 것입니다. 호출 오류는 다음과 같습니다
이
shutil.copy2(theFile.file.name,settings.UPLOAD_FILE_PATH + theFile.filename)
File "C:\Anaconda\lib\shutil.py", line 130, in copy2
copyfile(src, dst)
File "C:\Anaconda\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 13] Permission denied: 'c:\\users\\username\\appdata\\local\\temp\\tmpjy3gys'
을 편집 어디서 잘못된 것입니까? 다른 정보가 필요하면 알려주십시오.
당신은'IOError'의 전체 스택 추적도 문제를 재현 할 수있는 실행 가능한 미리보기도 제공, 그래서 잘못되면 무엇을 어디에 있는지 어렵다. [답변] (http://stackoverflow.com/a/26299440/2072035)에서 스 니펫을 실행하여 동일한 예외가 발생하는지 여부를 알려주십시오. – saaj
@saaj : 전체 오류 정보로 업데이트했습니다. – zennith