Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- View:
- <div class="accordion-item-content">
- <div class="block">
- <p><small>* Seu Registro Geral (RG)</small></p>
- <div class="button-action" style="" align="center">
- <div class="">
- <img src="img/small_placeholder.png" class="img-responsive img-thumbnail" id="imagem_rg" alt="" title="" />
- <input type="hidden" name="img_rg" id="img_rg"/>
- </div>
- <p class="segmented segmented-round">
- <button type="button" class="button button-round button-raised color-red" onclick="setImagemCamera()"><i class="fa fa-camera-retro"></i></button> </p> </div></div></div>
- JS:
- function setImagemCamera() {
- navigator.camera.getPicture(onSuccess, onFail, {
- quality: 50,
- allowEdit: true,
- destinationType: Camera.DestinationType.FILE_URI,
- correctOrientation: true
- });
- function onSuccess(imageData) {
- $("#imagem_rg").attr("src", imageData);
- $("#img_rg").val(imageData);
- uploadImagem(imageData);
- }
- function onFail(message) {
- toastMsg('Erro: ' + message.code, "danger");
- }
- }
- function uploadImagem(imageData) {
- var url = encodeURI(URL_CALL + "app/usuario/recebeImagem");
- var options = new FileUploadOptions();
- options.fileKey = 'file';
- options.fileName = id_ + "imagerg".jpg";
- options.mimeType = "image/jpg";
- options.httpMethod = "POST";
- options.chunkedMode = true;
- var params = {};
- params.id_pre_cadastro = id_;
- params.plataforma = device.platform;
- params.uuid = device.uuid;
- params.modelo = device.model;
- params.device_serial = device.serial;
- options.params = params;
- var ft = new FileTransfer();
- ft.upload(imageData, url, onUploadSuccess, onUploadError, options);
- function onUploadSuccess(message) {
- console.log(message);
- console.log(message.response);
- }
- function onUploadError(e) {
- console.log(e);
- $("#imagem_" + doc).attr("src", "assets/img/small_placeholder.png");
- toastMsg('Erro no upload', "danger");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement