Search code examples
djangofilechooser

How to use a file chooser in Django?


What I need is a button that I open the file explorer, select the file and then show the path of the file. What I've seen so far requires uploading the file and I just need the get the path. Is there another way that doesn't require uploading the file or it only can be managed like that?

Thanks


Solution

  • An <input type="file"/> will provide the functionality you seek. However the full file path is typically unavailable. Modern browsers replace it with C:\fakepath\<file> as revealing information on the web, such as directories, about the clients machine is a security problem if the site was infected by XSS (Cross-Site Scripting).