473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to allow only certain file types for upload?

I have an upload server control and i want to set it up in such a way that
allowed file types (extensions) can be specified in a property in the
property window. The different files types just separated by a comma for
instance. Right allowed file types are hardcoded into the array list and if
i need to add an addtional one i have to recompile each time. How can i get
the comma delimited string in the allowed files property and add each
individual file type to the array list? I have tried various things but
havent been able to get it yet.

Thanks
Ashok
Nov 18 '05 #1
1 2366
The way that you handle file uploads in DHTML is to use the <input
type="file> element, which doesn't have the same rich properties that you
would find in a Windows application for setting this property. (At least, I
am not aware of it if there are, and I just glanced at the docs to verify
that I wasn't missing anything obvious.) So, you have a couple of options.
First, you could implement some client-side event handling that would
retrieve the value of the control (which returns the file name) and check
the extension. Then, you only submit if you pass validation. Second, you
could implement an embedded WinForms or ActiveX control that gives you
richer functionality, at the expense of requiring people to trust your
controls to do what they say they do. Third, you could get lucky and
somebody could post back that I have, indeed, missed the property setting
that allows this. :-)

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Showjumper" <sh*******@grkjashdjkf.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
I have an upload server control and i want to set it up in such a way that
allowed file types (extensions) can be specified in a property in the
property window. The different files types just separated by a comma for
instance. Right allowed file types are hardcoded into the array list and
if
i need to add an addtional one i have to recompile each time. How can i
get
the comma delimited string in the allowed files property and add each
individual file type to the array list? I have tried various things but
havent been able to get it yet.

Thanks
Ashok

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
2
by: mano kumar | last post by:
hello, is there a way i can control what user upload to the webserver? i've created a upload feature and i dont know howto control what the user uploads. i want to allow my user to only upload...
3
by: Ryan | last post by:
How can I set the write permissions for a certian folder within a virtual directory using the web.config file? Essentially, I want to give the ASP.NET user write permissions to the "uploads"...
5
by: Jon Natwick | last post by:
I would like to limit the file types that users can upload. <input id="tbFileUpload" type="file" runat="server"> This setting looks like it should it work, but it's not working for me. ...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
0
by: Webmills | last post by:
Hi I have a form containing a File Upload Control, Required Field Validator (connected to the file upload control) RegularExpressionValidator (connected to the file upload control,...
1
by: gryffin | last post by:
im trying to do file extension checking but its not working :( i have the following in the head <script language="JavaScript"> extArray = new Array(".jpg", ".png", ".bmp"); function...
3
by: The Bicycling Guitarist | last post by:
Hello. I have many songs and essays pages that have been online more than ten years in some cases. These pages use HTML and CSS. Is there some way to allow visitors to add comments to these pages,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.