PythonWeb:在pycharm中的django项目上传至centos7中的nginx上部署时,文件上传路径问题

最近在学习使用django做项目,其中上传文件在本地测试很好,可是部署到centos7中的nginx时,总是提示文件路径找不到FileNotFoundError: [Errno 2] No such file or directory: '/mnt/vdb/Bioinformatics/static\\enhancerupload/fileTest08.fasta‘.

路径表示:

UPLOAD_DIR = 'static/enhancerupload'

  fileName1=’fileTest08.fasta‘

destination = open(os.path.join(settings.BASE_DIR, UPLOAD_DIR, fileName1), 'wb+') 

出错提示:FileNotFoundError: [Errno 2] No such file or directory: '/mnt/vdb/Bioinformatics/static\\enhancerupload/fileTest08.fasta‘.

解决办法:将static和enhancerupload分开os.path.join

destination = open(os.path.join(settings.BASE_DIR, 'static','enhancerupload', fileName1), 'wb+')

你可能感兴趣的:(django,django,python,centos)