Jump to content
  • 0

Limit file upload to picture from mobile camera


AlEll
 Share

Question

Hi! I´m reviewing Caspio as an alternative for my company business processes. In a particular use case, I need to limit the file upload type to only accept/allow in situ pictures taken with the phone camara. This, since it´s very important that older or faked pictures shouldn´t be uploaded or stored on the phones memory.

I´ve already searched on the documentation, but found nothing. I guess I missed something or maybe there is some JS code to achive this.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi ,

I found this HTML code to only upload image using camera: <input type="file" accept="image/*"  capture="camera"> , you may insert the code on the HTML block. I am not quite sure about saving the file using Javascript.

Here's the link for reference: https://stackoverflow.com/questions/23916566/html5-input-type-file-accept-image-capture-camera-display-as-image-rat

-Potato

Link to comment
Share on other sites

  • 0

Hi - Just wanted to share this solution. If you want to restrict file type in multiple fields, just like in this article: https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/restrict-file-types-that-can-be-uploaded-in-a-datapage/

You can use this code:

<script type="text/javascript">

var files = Array.from(document.querySelectorAll('#InsertRecordFIELDNAME1, #InsertRecordFIELDNAME2, #InsertRecordFIELDNAME3, #InsertRecordFIELDNAME4, #InsertRecordFIELDNAME5'));

var extensions = ['pdf'];

files.forEach(function(el) {
el.addEventListener('change', function(e) {

var ext = this.value.match(/.([^.]+)$/)[1];

if (!extensions.includes(ext)){

alert('Invalid file format. Please upload PDF only.');

this.value = '';

}
});});

</script>

Hope it helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...