10

I have the following code. It creates a new FileList to edit a FileList Objekt of an File Input to allow me to create a list of all the files the user wants to upload and give him the option to delete or reupload some of them:

function FileListItem(a) {
  a = [].slice.call(Array.isArray(a) ? a : arguments);
  for (var c, b = c = a.length, d = !0; b-- && d;) d = a[b] instanceof File;
  if (!d) throw new TypeError("expected argument to FileList is File or array of File objects");
  for (b = (new ClipboardEvent("")).clipboardData || new DataTransfer; c--;) b.items.add(a[c]);
  return b.files;
}

Unfortunatly it wont work on iOS and MacOS as the DataTransfer constructor does not exist. I get the following error:

[Error] TypeError: function is not a constuctor (evaluating 'new DataTransfer')

Here you can see the compatibility of a DataTransfer Object: developer.mozilla.org

Now my Question: Is there an alternative that works on Safari?

0 Answers0