apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 989 forks source link

WKWebView input=file support? #1065

Closed allanevargas closed 3 years ago

allanevargas commented 3 years ago

I've recently upgraded to WKWebView from UIWebView and this worked fine then and it works on android too. I have this input file element in one of my pages.

<input type="file" class="upload" id="file-upload-{{line.line_id}}" onchange="angular.element(this).scope().onFileSelect(angular.element(this).scope().$index);"/>

In onFileSelect I select the files uploaded to be sent to my server via $http.post

var element_name = "file-upload-" + $scope.lines[index].line_id;
var element = document.getElementById(element_name);
var files = element.files;

However, files is just of type blob, although it seems to have the mime type. The filename is also just "Blob" rather than the actual filename from the file browser on iOS.

Has there been a change to this on WKWebView where this is handled differently? How do I get a hold of the actual file uploaded on the input field for WKWebView?

allanevargas commented 3 years ago

So for some reason, the only issue here really is that the filename of $_FILES is just “Blob”. It still has the attributes of the file on upload, so what I did on my server was just given it a randomly generated filename when stored followed by the extension and this seems to have fixed the issue.

allanevargas commented 3 years ago

See thread.