getting file path
See original GitHub issueHello, i have an input of type file, i want to get the path from the input to my python script, for example electron provides an additional input.files[0].path field that allows for this to happen, since the default web browser path would look like this c:/fakepath/filename
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
How to Copy the Full Path of a File on Windows 10
Find the file or folder whose path you'd like to copy in File Explorer. Hold down Shift on your keyboard and right-click on...
Read more >How to get the complete path to a file or folder on Windows 10
Paths are needed when you have to move a Command Prompt or PowerShell window to a different directory or when you need to...
Read more >Show the Full Folder Path in File Explorer on Windows 10
Show the Full Folder Path in File Explorer on Windows 10 · 2. Click Options · 3. Select Change folder and search options,...
Read more >How to get full path of a file? - linux - Stack Overflow
Holding Shift and right clicking on a file in Windows Explorer gives you an option called Copy as Path . This will copy...
Read more >Get(FilePath) - FileMaker Pro
In Windows, the full path is file:/drive:/folder/filename for local files. For remote files, the full path is file://volume/folder/filename.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For security reasons it is not possible to get the file path through the browser as @ChrisKnott said. Using the Tkinter library, you can easily do it as shown in the example below.
app.py
main.html
I ran into this issue as well. Was hoping for some sort of solution like Electron as the OP mentioned. However, I understand why it doesn’t exist. I wasn’t a fan of the solutions given because you have to modify the UI and having a web frontend UI is the whole reason for the Eel library.
From the JS side we have the filename, last modified date, and file size in bytes. You can search filesystem on Python side for name match and weed out duplicates based on modified date & file size. Alternatively, you can calculate a checksum hash from the base64 file data on JS side and use that for searching on Python side. I’ll implement this and post here for those interested. I can’t imagine the run time is going to be great.
Edit: I implemented this two ways:
readAsArrayBuffer
and send the byte array as a variable to python via eel exposed function that is then saved to a temporary file and therefore you know the path. Downsides: redundant data. Takes a LONG time for the data to be passed to Python even for files < 1MB.I’ll try setting electron as the client-side browser and maybe I can get access to the file path field it attaches as @ChrisKnott suggested and report back.
Edit 2: following #57 and the Electron-Eel minimal example I was able to get Electron up and running as my client with Eel. All
<input type="file">
now have apath
variable attached to them with the absolute path. A little bit of setup but works great and no hacky solutions necessary. This is the way to go 👍