Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a real path of file type input #87

Closed
sanket143 opened this issue Aug 25, 2020 · 12 comments
Closed

Getting a real path of file type input #87

sanket143 opened this issue Aug 25, 2020 · 12 comments

Comments

@sanket143
Copy link

Is your feature request related to a problem? Please describe.
I am trying to get a the real path of file selected in <input type="file" id="myFile"> but I dunno how to.

I tried document.getElementById("myFile").files which gives array of File which contains following information.

lastModified: 1597767566000
name: "filename.py"
size: 859
type: "text/x-python"
webkitRelativePath: ""

Describe the solution you'd like
Electron adds a path property in File object. I don't know how exactly it is happening and will it be possible in Tauri
but this seems to be one possible solution to me.
https://github.com/electron/electron/blob/master/docs/api/file-object.md

@sanket143
Copy link
Author

Okay got the solution it's simply

import { open, save } from "tauri/api/dialog"

async handler(){
  let filepath = await open()
}

dialog is all for this. RTFD 🤦‍♂️

@ken0x0a
Copy link

ken0x0a commented Sep 8, 2020

I had the same issue when I was trying to drag and drop a file.

Could you reopen this issue?

@sanket143 sanket143 reopened this Sep 8, 2020
@ken0x0a
Copy link

ken0x0a commented Sep 28, 2020

It seems winit supports this feature.
But, sadly, the webview_official doesn't use "winit", so it doesn't work.

@ken0x0a
Copy link

ken0x0a commented Feb 28, 2021

@nothingismagick Could you move this ISSUE also to wry repo?
I think this issue is related to handling window event (at least on macOS).

@nklayman nklayman transferred this issue from tauri-apps/tauri Feb 28, 2021
@wusyong wusyong closed this as completed Mar 9, 2021
@ken0x0a
Copy link

ken0x0a commented Mar 9, 2021

@wusyong Is this feature implemented?
If so, could you add a reference please?

@wusyong
Copy link
Member

wusyong commented Mar 10, 2021

Ah sorry, closed this because we now have a file drop handler for it.
See dragndrop example to see how it works.

@ken0x0a
Copy link

ken0x0a commented Mar 11, 2021

@wusyong Thank you for the line!
Can we get absolute path for the file?

@wusyong
Copy link
Member

wusyong commented Mar 11, 2021

Yes, it's the absolute path.

@mihirsamdarshi
Copy link

Hi, is there an example of how I would handle dragging and dropping files using the JS Tauri API? I have a React component that utilizes the drag and drop HTML APIs with event listeners, and it can handle it just fine in a web browser, but I am unsure how I would use that to hook into my Tauri application?

@FabianLars
Copy link
Member

@mihirsamdarshi
Listen to the tauri://file-drop and tauri://file-drop-hover (and tauri://file-drop-cancelled) events with tauri's event listener: https://tauri.studio/en/docs/api/js/modules/event/#listen

@mihirsamdarshi
Copy link

@FabianLars thank you!

@Jan-Eckerlein
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants