How to use input type file in phonegap?

南楼画角 提交于 2019-11-29 06:45:32

You can't use input file on Phonegap. It's not supported. You need make something like this:

function uploadDatabase(callback) {
// file.entry accessible from global scope; see other tutorial
var filepath = file.entry.fullPath,
    uploadOptions = new FileUploadOptions(),
    transfer = new FileTransfer(),
    endpoint = "http://facepath.com/payload";

uploadOptions.fileKey = "db";
uploadOptions.fileName = "database.db";
uploadOptions.mimeType = "text/plain";

transfer.upload(filepath, endpoint, transferComplete,
                        transferError, uploadOptions);

}

in mime type put the type of file

A. Magalhães

I wrote this answer "You can't use input file on Phonegap. It's not supported.". Check the solution on https://stackoverflow.com/a/13862151/1853864

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!