SSS*_*SSS 10 javascript android sencha-touch cordova
如何在phonegap中使用html文件属性?这样我可以从我的Android设备浏览任何.txt文件并将其上传到服务器?
我在phonegap文档中读取了文件传输方法,但据说可以通过url将文件上传到服务器.但是可以通过以下方式正常工作:
<input type=file /><button>upload</button>
Run Code Online (Sandbox Code Playgroud)
输入类型="文件"接受="图像/*"在手机间隙中不起作用?我看了这个链接,但只说图像.
但是如何上传文本文件?
任何帮助?
谁有人回答这个问题?
Tom*_*eau -1
您无法在 Phonegap 上使用输入文件。不支持。你需要做这样的事情:
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);
Run Code Online (Sandbox Code Playgroud)
}
在 mime type 中输入文件类型