当前位置:首页 » 文件管理 » cordova拍照上传

cordova拍照上传

发布时间: 2022-09-21 11:25:29

Ⅰ angularjs ionic cordova做app有关时间插件的

配置ngcordova
(插一句,之前由于没配置ngcordova直接报错[$injector:unpr] Unknown provider: $cordovaCameraProvider<-$cordovaCamera)
进入到工程目录,使用npm工具安装
npm install ngCordova
2
然后将ng-cordova.js或者ng-cordova.min.js添加到index.html中的cordova.js引入之前
<script src="lib/ngCordova/dist/ng-cordova.js"></script><script src="cordova.js"></script>
Ionic 拍照上传插件org.apache.cordova.camera
3
然后在angular中添加ngCordova依赖,
angular.mole('myApp', ['ngCordova'])
Ionic 拍照上传插件org.apache.cordova.camera
4
装插件 cordova plugin add org.apache.cordova.camera
Ionic 拍照上传插件org.apache.cordova.camera
END
调用
1
在相应控制器加上$cordovaCamera,拍照返回图片文件的实际存储地址
$scope.takePhoto=function(){
var options = {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
};

$cordovaCamera.getPicture(options).then(function(imageURI) {
alert(imageURI);
$scope.imageSrc= imageURI;
}, function(err) {
// error
});
}

Ⅱ ionic拍照上传一定要用插件吗

ngCordova提供了调用手机API的接口,这个肯定是要的。至于拍照插件,你想自己写也可以,不过人家都提供给你了,你都不用,这。。。。

Ⅲ cordova 拍照怎么设置不让切图

你好,停止运行的话你可以在设置--应用程序--全部--找到相应的程序--清理数据重启手机观察的。这里的清理数据不会丢失资料。游戏无反应或者反应慢,一般是以下几个因素导致的:1、一次运行多个应用程序,建议清理后台 2、下载了很多第三方软件,导致中毒或者不兼容。建议卸载非软件商店下载的软件 3、缓存文件过多长时间没有清理,建议清理缓存。清理缓存方法:在手机关机后,同时按电源键和音量减8秒左右,进入recovery模式,选择清除缓存,清理后重启手机,您再观察看看。清理缓存不会丢失资料,请您放心的,同时也请您不要选错。
若您还有其他的问题咨询,您可以进入OPPO企业平台向客服咨询提问喔!

Ⅳ wex5 拍照无法保存在本地相册

嗨!

根据您描述的问题,建议您先备份重要数据,然后进入Recovery清空所有数据,开机之后暂时不要还原数据,看看是否可以解决问题。(备份:安全中心-备份,备份您需要的数据。清空数据:关机状态下,按住音量加键和关机键,等出现开机画面时松手,即可进入Recovery。进入Recovery>中文>清除数据>清空所有数据.)。
如果没恢复任何软件可以正常使用,那很有可能您的问题是第三方软件引起的,请您恢复备份的时候,暂时不要恢复第三方的安全软件,不要获取root权限。尝试可否正常。

更详细的描述问题有助于网友理解你遇到的麻烦,帮助你更准确的解决问题。谢谢你支持小米手机!
这样可以么?

Ⅳ html5 如何调用手机相册,进行上传照片

cordova
用代码调用硬件,这里面有个方法可以调用手机的摄像头,里面我记得还有个功能查看手机相册

Ⅵ angular+ionic中如何使用cordova的插件

1.即使我们将移动端web页面做得和原生应用及其相似,在我们的页面中也无法像原生应用那样调用原生的能力,当然通过输入框触发键盘、图库、拍照等操作不在这里“调用原生能力”的范畴。

2.单纯的web页面不能提交到应用商店被用户使用。

然后,我们分别就它们之间的关系做出解释:

Ionic和Angular

首先要明确的是Ionic是Angular的衍生品,Angular是单独的JS库,和jQuery一样能够独立用于开发应用,而Ionic只是对Angular进行了扩展,利用Angular实现了很多符合移动端应用的组件,并搭建了很完善的样式库,是对Angular最成功的应用样例。即使不使用Ionic,Angular也可与任意样式库,如Bootstrap、Foundation等搭配使用,得到想要的页面效果。

Ionic/Angular和Cordova

可能会有人被问道:“Cordova比Ionic/Angular好吗?”,这就很尴尬了,根本是毫无意义的问题。它们在混合开发中扮演的是不同的角色–Ionic/Angular负责页面的实现,而Cordova负责将实现的页面包装成原生应用(Android:apk;iOS:ipa)。就像花生,最内层的花生仁是Angular,花生仁的表皮是Ionic,而最外层的花生壳则是Cordova。包装完成之后我们的页面才有可能调用设备的原生能力,最后才能上传到应用商店被用户使用。

Ionic/Angular和Cordova插件

关于Cordova插件要明确以下几点:

Cordova插件的作用是提供一个桥梁供页面和原生通信,首先我们的页面不能直接调用设备能力,所以需要与能够调用设备能力的原生代码(Android:java;iOS:OC)通信,此时就需要Cordova插件了。

Cordova插件能够再任何Cordova工程中使用,和使用什么前端框架(如Ionic)无关。

Ionic 2中封装了Ionic Native,方便了Cordova插件的使用,但在Ionic 2中仍然可以像Ionic 1中一样使用Cordova插件,Ionic Native不是必须的。

即使在Ionic 2中使用了Ionic Native,也首先需要手动添加插件,如:cordova plugin add cordova-plugin-pluginName。

Ⅶ cordova camera插件IOS下使用不正常

是否可以提供一个简单的demo程序(或是直接在我们的标准示例源代码上进行修改),能够重现上面的现象,我们好让iOS的开发工程师直接帮您调试一下,看是什么地方有冲突,谢谢。

Ⅷ 移动开发问题。一段文件上传代码用浏览器可以在手机执行,但cordova打包后无法在手机端执行

变成么?不懂得的

Ⅸ $cordovafiletransfer.upload怎么传参

html代码:
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding right ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<!-- 照相机 -->
<script type="text/javascript" src="js/camera.js"></script>
<input type="button" value="take pictures" onclick="snapPictures()" />
<img style="width:100px;height:100px;position:absolute;left:100px;top:50px;" id="myImage" />

<!-- 地理位置 -->
<script type="text/javascript" src="js/geolocation.js"></script>
<input type="button" value="location" onclick="getLocation()" />

<!-- 文件传输 -->
<script type="text/javascript" src="js/fileTransfer.js"></script>
<input type="button" value="fetchFile" onclick="fetchPictures()" />
<!-- <input type="button" value="fileTransfer" onclick="startTransfer()" /> -->

</body>
</html>

js代码:
/**选择图片库***/
function fetchPictures(){
navigator.camera.getPicture(fetchPictureSuccess, fetchPictureFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,//存储照片的数据/路径
sourceType : Camera.PictureSourceType.PHOTOLIBRARY ,//打开系统的图片库
encodingType: Camera.EncodingType.JPEG,
mediaType:Camera.MediaType.PICTURE,
popoverOptions : CameraPopoverOptions,
saveToPhotoAlbum: true
});
}
function fetchPictureSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
picUrl = imageURI;

/**文件上传start***/
var serverUri = encodeURI('http://192.168.1.101:8080/testTransfer/test.do');
function fileTransferSuccess(result) {
alert("success");
alert("Code = " + result.responseCode + "Response = " + result.response
+ "Sent = " + result.bytesSent);
}
function fileTransferError(error) {
alert("fail");
alert("An error has occurred: Code = " + error.code + "upload error source " + error.source
+ "upload error target " + error.target);
}

var fileUploadOptions = new FileUploadOptions();
fileUploadOptions.fileKey = "file";
fileUploadOptions.fileName = picUrl.substr(picUrl.lastIndexOf('/')+1);
fileUploadOptions.mimeType = "image/jpeg";
// fileUploadOptions.chunkedMode = false;

var fileTransfer = new FileTransfer();

alert("picUrl : "+picUrl + "******serverUri : " + serverUri);
// fileTransfer.onprogress = function(progressEvent) {
// if (progressEvent.lengthComputable) {
// loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
// } else {
// loadingStatus.increment();
// }
// };
fileTransfer.upload(picUrl, serverUri,fileTransferSuccess, fileTransferError, fileUploadOptions);

/**文件上传end***/

}

function fetchPictureFail(message) {
alert('Failed because: ' + message);
}

server端JAVA:

package com.cn.server;
import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
/**
* Servlet implementation class Test
*/
@WebServlet("/Test")
public class Test extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Doing post....");
System.out.println(request.getRequestURI());
/**
* The base upload directory. In this directory all uploaded files will
* be stored. With the applet param tag 'directory' you can create a
* subdirectory for a user.
* See http://www.javaatwork.com/parameters.html#directory for more
* information about the 'directory' param tag. For a Windows environment
* the BASE_DIRECTORY can be e.g. * 'c:/temp' for Linux environment '/tmp'.
*/

boolean isMultipart = ServletFileUpload.isMultipartContent(request);

// check if the http request is a multipart request
// with other words check that the http request can have uploaded files
if (isMultipart) {

// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();

// Create a new file upload handler
ServletFileUpload servletFileUpload = new ServletFileUpload(factory);

// Set upload parameters
// See Apache Commons FileUpload for more information
// http://jakarta.apache.org/commons/fileupload/using.html
servletFileUpload.setSizeMax(-1);

try {
String directory = "";
// Parse the request
List items = servletFileUpload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();

// the param tag directory is sent as a request parameter to
// the server
// check if the upload directory is available
if (item.isFormField()) {
String name = item.getFieldName();
if (name.equalsIgnoreCase("directory")) {
directory = item.getString();
}
// retrieve the files
} else {
// the fileNames are urlencoded
String fileName = URLDecoder.decode(item.getName());
File file = new File(directory, fileName+".jpeg");
file = new File("D:\\androidApp图片\\", file.getPath());
// retrieve the parent file for creating the directories
File parentFile = file.getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
// writes the file to the filesystem
item.write(file);
}
}
} catch (Exception e) {
e.printStackTrace();
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
response.setStatus(HttpServletResponse.SC_OK);

} else {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}

server端web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>testTransfer</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>com.cn.server.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test.do</url-pattern>
</servlet-mapping>

热点内容
我的世界迪士尼神奇宝贝服务器地址 发布:2024-10-10 09:03:02 浏览:556
win7存储并显示 发布:2024-10-10 09:02:30 浏览:550
oracle数据库导出 发布:2024-10-10 08:34:56 浏览:363
androidn特性 发布:2024-10-10 08:30:41 浏览:729
存储过程修改记录 发布:2024-10-10 08:23:28 浏览:58
呱呱编程 发布:2024-10-10 08:12:54 浏览:895
androidoa 发布:2024-10-10 08:07:14 浏览:894
安卓手机怎么关掉开了的游戏 发布:2024-10-10 07:50:14 浏览:681
idea新建java类 发布:2024-10-10 07:50:12 浏览:71
教务处的账号和密码是什么 发布:2024-10-10 07:47:51 浏览:790