• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Prevent certain data types from Attachment field

Hello experts ,
is there any way to prevent user from uploading certain data types to the attachment field? i want to insert only picture files and reject all other file types supported by the attachment field by showing a warning message.
How can this be achieved?
0
stathisx
Asked:
stathisx
  • 4
3 Solutions
 
Tony BarkdullCommented:
In you file upload, use this to specify type and size. This is from my asp page

'The the properties of the upload
File.ValidFileTypes = "jpg,gif,png"
File.MaxSize = 1024*1024
File.Overwrite = false 'Do not overwrite, create unique filename
0
 
stathisxAuthor Commented:
there is no such property in the attachment field !
0
 
stathisxAuthor Commented:
there is .filetype that may be used in vba to control which data types should be allowed ( just a thought)
0
 
stathisxAuthor Commented:
i found the solution :

Private Sub uploadpath_BeforeUpdate(Cancel As Integer)
If Me.uploadpath.FileType <> ".jpg" Or Me.uploadpath.FileType <> ".png" Or Me.uploadpath.FileType <> ".jpeg" Then
MsgBox "denied attachment"
Cancel = True
End If
End Sub

it does the job :)
0
 
stathisxAuthor Commented:
i found that the filedata property for the attachment field does what i really wanted. so in before update event of the attachment field a used this code to validate the attachment uploaded and if does not meet my criteria to reject it.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now