angularjs – 如何使用ngcordova文件传输插件将拍摄的图像传输到
我正在尝试将图像上传到我的FTP.
到目前为止我所获得的是这个plnkr 我的cordova文件传输看起来像 $scope.upload =function(){ var options = { fileKey: "file",fileName: "gopi",chunkedMode: false,mimeType: "image/jpeg",params : {'user_token':'Chandru@123','user_email':'wepopusers'} // directory represents remote directory,fileName represents final remote file name }; console.log(options); $cordovaFileTransfer.upload('ftp://308.3d8.myftpupload.com/',MyService.getImgPath(),options) .then(function(result) { // Success! console.log(result); console.log("SUCCESS: " + JSON.stringify(result.response)); alert('ftp success'); },function(err) { // Error console.log(err); alert('ftp fail'); console.log("ERROR: " + JSON.stringify(err)); },function (progress) { // constant progress updates console.log(progress); }); }; 我对cordova文件的错误函数的响应如下
我有按钮TakePicture,它将拍摄照片并显示给用户,我还有一个使用cordovafiletransfer $scope.upload上传的功能. 我的ftp主机是ftp://308.3d8.myftpupload.com/用户名和密码是在我的编码中给出的我有一个名为gopi的文件夹名称,我的图像应存储在其中. 我拍摄的图像的路径是在imageURI参数中,所以我使用服务来设置路径. 步骤我很困惑
UPDATE 感谢gandhi的回答https://github.com/xfally/cordova-plugin-ftp我如何设法连接到没有multipart的ftp. 但是在这方面面临着错误
我不知道第一个论点和第二个论点是什么.
以上行成功完全发布到我的ftp但我无法发布存储在我的ping变量中的图像. https://plnkr.co/edit/ETGmdl4B0d5dlHWdJQ9m?p=info 解决方法
第一个问题的答案可以在文件传输插件的官方文档中找到.摘录如下,
options: Optional parameters (Object). Valid keys: fileKey: The name of the form element. Defaults to file. (DOMString) fileName: The file name to use when saving the file on the server. Defaults to image.jpg. (DOMString) httpMethod: The HTTP method to use - either PUT or POST. Defaults to POST. (DOMString) mimeType: The mime type of the data to upload. Defaults to image/jpeg. (DOMString) params: A set of optional key/value pairs to pass in the HTTP request. (Object,key/value - DOMString) chunkedMode: Whether to upload the data in chunked streaming mode. Defaults to true. (Boolean) headers: A map of header name/header values. Use an array to specify more than one value. On iOS,FireOS,and Android,if a header named Content-Type is present,multipart form data will NOT be used. (Object) 查看此link了解更多信息. 对于第二个问题,尝试在错误回调函数中获取错误代码并尝试缩小问题范围. 更新:我想使用文件传输插件无法进行ftp上传.插件定义本身指出“FileTransfer对象提供了一种使用HTTP多部分POST或PUT请求上传文件以及下载文件的方法” 对于ftp上传,您可能需要查看ftp client. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |