How can we validate whether attachment is PDF or word file or image or excel file

kranthi2
Tera Expert

Hi,

Can some one will help on How can we validate whether attachment is PDF or word file or image or excel file.
 
I want a functionality that 
 
For some of the users i want only PDF format is only able to submit 
For some of the users i want only excel files only submit 
for some of the users i want to only image formats
 
Is it possible to validate the attachments
 
 
4 REPLIES 4

Mark Manders
Mega Patron

Maybe subscribe to this one: https://www.servicenow.com/community/itsm-forum/how-can-we-validate-whether-attachment-is-pdf-or-wor...


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Shivam Techlene
Tera Guru

Hi @kranthi2 ,

 

I think this is not reproducible. Cause we cannot verify the extension/type of the attachment before it has been uploaded and stored in the "sys_attachment" table. In your case, we can do one thing, we can delete the uploaded attachment if it's type doesn't comply with the current logged in user/group once it is stored in the attachment table and display an error message to the user.

 

Kindly mark my response helpful and correct if it helps your understanding.

 

Thanks & Regards,
Shivam Jaiswal

Adam43
Tera Contributor

does any of this validation actually examine the coding of the file of just look at the attachment's extension value?  ie- can it check for if someone just changed the name of the file from virusmalware.exe to safe.pdf  ?

No. An attachment is an attachment and the extension is evaluated. The Antivirus config will take care of content that can be dangerous, no matter the extension.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark