Jump to content

Require Specific File format On File Upload Field


Recommended Posts

I am trying to only allow specific file type upload using JS 

<SCRIPT LANGUAGE="JavaScript">
document.getElementById("Files").setAttribute("accept","application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
</SCRIPT>

Where 'Files' is the table field name. But it still allows me to upload a PNG file. Am i doing something wrong?

Link to post
Share on other sites

Hi DavidKennett,

I have used following JS in my Tablular Report Datapage (inline insert enabled) which hides/disables the "Add" button if uploaded file has any other extension except the following: .pdf, .doc, .docx, .xls, .xlsx.

<SCRIPT LANGUAGE="JavaScript">

var v_file = document.getElementById('InlineAddPhoto');
var v_btn = document.getElementById('Mod0InlineAdd');

v_file.addEventListener('change', function(v_e){
 var v_ext = (v_file.value || '').split('.').pop().toLowerCase();
 if (!['pdf', 'doc', 'docx','xls','xlsx'].contains(v_ext)){
 v_btn.disabled;
 alert('Please attach a document with following extension: .pdf, .doc, .docx, .xls, .xlsx'); // pop-up alert message 
 v_btn.style.display="none";}

 else {v_btn.style.display="inline-block";}
});
</SCRIPT>

Please paste this snippet of code into the Footer.

Hope this helps.

 

Regards,

vitalikssssss

 

Link to post
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
Reply to this topic...

×   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...
×
×
  • Create New...