One way to preserve the directory structure when uploading local files to the UIWebview on an iPhone is to use a file URL scheme.
First, get the local file path using a file manager:
let fileManager = FileManager.default
guard let filePath = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("myFolder/myFile.pdf") else {
return
}
Then, create a file URL with the path and load it into the webview:
let fileURL = URL(fileURLWithPath: filePath.absoluteString)
let request = URLRequest(url: fileURL)
webView.load(request)
This approach will preserve the directory structure of the file when loading it into the webview.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-05 22:35:32 +0000
Seen: 10 times
Last updated: May 05 '23
What is Fullscreen Activity in Android?
What does 'Invalid argument (callbackUrlScheme): must be a valid URL scheme' mean?
How can SSL passthrough be implemented with Traefik in Kubernetes?
What is authentication using C# ASP.NET Core MVC?
What are the steps to create a semi-circular shape divided into 8 parts using HTML, CSS, or SVG?
What is the way to name parameters and REST API urls in Spring Boot?
How can ASP.NET Core be configured to incorporate various authorization strategies?