简体   繁体   中英

Cocoa Webview HTML link to a desktop image file

I have a webView that loads an HTML from the app bundle. I want to open an image located on the desktop of my MAC within this HTML file. I just need some help on what path I need to use in my HTML file. Please note that I can't use any native code in this case, I need the path that can load this image. I tried something like this but it failed. file:////Users/MacUser/Desktop/image.jpg

Any help will be highly appreciated.

Amy

I think /Users/MacUser/Desktop/image.jpg will work. But if you app is sandboxed, you won't be able to show the image. Because inside the sandbox your app cannot access the file system freely.

Ref: https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM