當前位置:首頁 » 文件管理 » 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>

熱點內容
termux如何搭建伺服器 發布:2024-10-10 10:18:05 瀏覽:736
中國石化的電話服務密碼是多少 發布:2024-10-10 10:16:46 瀏覽:41
婚紗店宣傳片視頻腳本 發布:2024-10-10 10:08:55 瀏覽:868
android寫入文件 發布:2024-10-10 10:08:11 瀏覽:434
怎麼打開文件夾的路徑 發布:2024-10-10 10:08:06 瀏覽:60
ec伺服器怎麼有小提示 發布:2024-10-10 10:08:04 瀏覽:494
我的世界迪士尼神奇寶貝伺服器地址 發布:2024-10-10 09:03:02 瀏覽:559
win7存儲並顯示 發布:2024-10-10 09:02:30 瀏覽:552
oracle資料庫導出 發布:2024-10-10 08:34:56 瀏覽:364
androidn特性 發布:2024-10-10 08:30:41 瀏覽:730