问题
Is there a reason to still use the FileTransfer object with the availabilty of sending blobs/files or even multiple files in forms via XmlHttpRequest2 ?
Using html5 makes it a lot easier to run the same app in a modern browser as well and reduces code. Or are there any advantages to the FileTransfer object?
Especially FormData seems to do the same, though it runs only on the latest browsers.
回答1:
It seems the FormData & file implementation is not working properly on all systems, yet. Therefore it's probably better to use FileTransfer.
EDIT:
I got it working without FileTransfer using XmlHttpRequest. For sending I append a blob to a FormData object, however I construct the blob from an arraybuffer (file.readAsArraybuffer). For receiving files I set the responseType to 'arraybuffer'. This works on Chrome and mobile Safari (i.e. Phonegap).
来源:https://stackoverflow.com/questions/17480725/is-phonegaps-filetransfer-object-obsolete-with-xmlhttprequest2