UnityStandaloneFileBrowser icon indicating copy to clipboard operation
UnityStandaloneFileBrowser copied to clipboard

Full path on WebGL

Open FanEric opened this issue 5 years ago • 5 comments

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!

FanEric avatar May 15 '19 06:05 FanEric

Hi,

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

gkngkc avatar May 15 '19 11:05 gkngkc

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.

FanEric avatar May 16 '19 00:05 FanEric

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.

gkngkc avatar May 16 '19 10:05 gkngkc

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

FanEric avatar May 29 '19 09:05 FanEric

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

minhajjaved-aai avatar May 20 '21 09:05 minhajjaved-aai