gkngkc / UnityStandaloneFileBrowser

A native file browser for unity standalone platforms
MIT License
2.01k stars 317 forks source link

Full path on WebGL #61

Open FanEric opened 5 years ago

FanEric commented 5 years ago

Hi, when I use this plugin to select a file on my computer on WebGL build, the "OnFileUpload(string url)" method returns url like "http://localhost:8080/b9d3a922-816f-4a4c-9004-c1aa5e449380". Can I get the actual path of the selected file like"D:/xxx.xxx"? Thanks!

gkngkc commented 5 years ago

Hi,

No, you can’t. Due to security reasons, browsers not allowed to read file system.

FanEric commented 5 years ago

Hi,

No, you can’t. Due to security reasons, browsers not allowed to read file system.

Thank you for your reply, and what about the name? Is there a method I could get the name of the file selected? I'm using this plugin to upload file, but before that, I should make sure the file's name is different from my project. Hope I expressed clearly.

gkngkc commented 5 years ago

I think its possible, on StandaloneFileBrowser.jslib line 44, you can get file name with event.target.files[0].name (or multiple name if you support multiselect)

But sending name to unity side is trickier since unity’s SendMessage only supports one argument you have to concat urls and names and differentiate them on unity side.

FanEric commented 5 years ago

Sorry for replying late. Yes, it worked! And great thanks to you!

minhajjaved-aai commented 3 years ago

Hi @FanEric did you get selected file name on webGL? I'm really stuck on it if you can help?