Solved

Prevent certain data types from Attachment field

Posted on 2011-09-25
5
309 Views
Last Modified: 2012-05-12
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
Comment
Question by:stathisx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 10

Expert Comment

by:Tony Barkdull
ID: 36596039
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
 
LVL 1

Assisted Solution

by:stathisx
stathisx earned 0 total points
ID: 36596065
there is no such property in the attachment field !
0
 
LVL 1

Assisted Solution

by:stathisx
stathisx earned 0 total points
ID: 36596079
there is .filetype that may be used in vba to control which data types should be allowed ( just a thought)
0
 
LVL 1

Accepted Solution

by:
stathisx earned 0 total points
ID: 36596164
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
 
LVL 1

Author Closing Comment

by:stathisx
ID: 36890339
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question