Ionic-v1 input=file on iOS is of type Blob instead of actual file type on WKWebView


I currently have an element for input type file on my app for uploading files via the file browser.

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

on the onFileSelect function, I access it via:

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

However, no matter what the type of file I upload, it seems to take it in as a Blob. Even the filename is “Blob” even though it has the mime type. I recently upgraded from UIWebView to WKWebView so i’m not sure if that’s the issue but I can’t seem to find anything on it. It worked before on UIWebView and it also currently works on Android. On Android, it takes it in as whatever file it is.

Is there something I’m missing here? Do I need to convert it to file specifically for iOS? I take this file and upload it to my backend (PHP) via

Just to reiterate, this worked previously on UIWebView. Has something changed on WkWebView where this no longer works or if it needs to be done a different way?

Yep, this is what I already have. I’m wondering if there’s anything I need to change specifically for WKWebView since it worked previously on UIWebView.

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.

1 Like