我试图通过AngularJs中的$http
提供商发布input[type=file]
个对象。
在浏览器中,可以将FormData
的文件值附加到$http
并通过formData.append('file', inp.files[0], 'nai.jpg');
formData.append('text', 'hello');
$http.post('url', formData, {
transformRequest: angular.identity,
headers: { 'Content-Type': undefined }
});
发布。类似的东西:
input[type=file]
服务器获得了两个正文字段的发布请求。但在Cordova应用中,fileURI
不可用,因此我可以通过这样的原生插件从用户那里获得navigator.camera.getPicture(function(fileURI) {
// i got fileURI
});
:
fileURI
现在,请解释我如何将formData
作为文件发送到$http
并由FileTransfer
Angular提供商发送(不是private static HashMap<String, String> doctorcredentials = new HashMap<String, String>();
doctorcredentials.put("doctor","Test1234!");
)。
答案 0 :(得分:0)
如果我们在配置对象中指定选项,Cordova还会提供图像的base64数据。这样您就可以将相同的base64数据传递给服务。
var cameraOptions = {
destinationType : 0 /*(DATA_URL -- For base64 data)*/
}
navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);