Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
Envíe una foto al formulario usando cordova-plugin-camera

Usando cordova-plugin-camera, puedo llamar a la cámara del dispositivo y tomar una foto, pero no sé qué hacer desde allí. Quiero enviar la foto tomada a un formulario y subirla a mi servidor usando javascript. Aquí hay un ejemplo de mi código:

 <html> <script> function capturePhoto() { navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, correctOrientation: true, destinationType: Camera.DestinationType.FILE_URI, targetWidth: 100, targetHeight: 100 }); } function onPhotoDataSuccess(imageData) { // Uncomment to view the base64 encoded image data alert("Success: " + imageData); } function UploadUserImage(){ if($("#selectStudentImage").val() == ""){ return; } else{ ShowHideBigLoading(); var fileName = ""; var fileExtension = ""; fileName = $("#selectStudentImage").val(); fileExtension = fileName.substr((fileName.lastIndexOf('.') + 1)); fileExtension = fileExtension.toLowerCase(); //Checking the file size if($("#selectUserImage")[0].files[0].size > 20000000){ navigator.notification.alert("File size is too large to upload.", null, 'Error', 'Okay'); return; } //Checking to make sure that the file name is not too long if(fileName.length > 100){ navigator.notification.alert("File name is too large. Please reduce the files name and try again.", null, 'Error', 'Okay'); return; } if($.inArray(fileExtension, ["doc","docx","jpg","jpeg","png","pjpeg","txt","gif","pdf"]) == "-1"){ navigator.notification.alert("File Type Unsupported", null, 'Error', 'Okay'); return; } setTimeout(function(){ $("#form_UploadEditUserPhoto").submit(); },500); return; } } </script> <button onclick="capturePhoto();">Take Photo</button> <form style="display: block; position: absolute;" action="" name="form_UploadEditUserPhoto" id="form_UploadEditUserPhoto" enctype="multipart/form-data" method="post" class="form-horizontal"> <input type="hidden" name="FormName" value="EditUserPhoto" /> <input style="display: none;" id='selectUserImage' name="file" type="file" onchange="return UploadUserImage(event)"> </form> </html>

Cualquier ayuda sería muy apreciada. También tengo disponible ajax para subir una imagen, si no hay forma de hacerlo por formulario.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!