Django FILES upload: path and filename

有些话、适合烂在心里 提交于 2019-12-13 02:13:16

问题


When an uploaded file is received by the Django server, its name can be read using UploadedFile.name

If filename in the multipart-data content contains a path like: '/a/b/c', UploadedFile.name seems to contain '/c' . How can I retrieve the full path and not just the file name.

Thanks.

Laurent Luce


回答1:


You can't. Many browsers won't ever send the whole path, as a security measure to prevent information leakage.

What's more you know nothing about the file and path naming conventions in force on the user's computer, so there is little you can do with the submitted name. Don't do anything that relies on a submitted filename.



来源:https://stackoverflow.com/questions/1993413/django-files-upload-path-and-filename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!