开发者

GWT creating a link to a file on computer

String link = "file:///c:/test.csv";
Html htmlLink = new HTML("<a href=\"" + link + "\">Download CSV File</a>");

I created the above link and I'm adding it to a vertica开发者_运维百科l panel. When I click on the link, nothing happens...Is this the correct way of creating a link to a file on computer?


No, there will be discrepancies depending on OS and browser.

This will explain it all, and if you can achieve what you want: http://en.wikipedia.org/wiki/File_URI_scheme

Works on windows in FF and Chrome. Doesn't seem to work in IE9.
<a href="file://localhost/C:\test.csv">Download CSV File</a>

This work's in IE, as long as your not logged into a domain:

Works in IE9, Chrome, and FF on a local account, may not work logged into domain account.
<a href="file:///C:\test.cvs">Download CSV File</a>

This will only serve to download a file local to the user through their browser, but why would I download a file already on my machine.

If the file is on your server/machine, then you should make the file accessible on the web server, by way of virtual directory. Then you could do:

String link = "/temp/test.csv";
Html htmlLink = new HTML("<a href=\"" + link + "\">Download CSV File</a>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜