admin管理员组文章数量:1418113
I am write a wkwebview application in macos where I want to enable file upload to my website loaded in wkwebview. I found few articles telling to use runOpenPanelWithParameters which runs for me but I stuck in a problem.
Problem:
The method works to open the file dialog, but I'm stuck on how to properly handle the file(s) selected by the user and upload them to my website. i.e: If website only want img upload, from chrome it fade out files other then img, I want to achieve same in wkwebview.
- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * _Nullable))completionHandler {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
openPanel.canChooseFiles = YES;
openPanel.canChooseDirectories = NO;
openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
[openPanel beginWithCompletionHandler:^(NSModalResponse result) {
if (result == NSModalResponseOK) {
completionHandler(openPanel.URLs);
} else {
completionHandler(nil);
}
}];
}
版权声明:本文标题:swift - Unable to Specify File Types in WKWebView Using runOpenPanelWithParameters on macOS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745271564a2650923.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论