473,395 Members | 1,440 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,395 software developers and data experts.

FileUpload FileSpec

Is there any way to tell the FileUpload control to produce a clientside dialog
with a particular filespec filter on it.

For example I would like to restrict users to only uploading pdf files.

Thanks

--
Rory
Aug 21 '08 #1
3 1000
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
string extension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (extension == ".pdf")
{
//your upload code...
}
}


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Rory Becker" <ro********@newsgroup.nospamwrote in message news:3a**************************@news.microsoft.c om...
Is there any way to tell the FileUpload control to produce a clientside dialog with a particular filespec filter on
it.

For example I would like to restrict users to only uploading pdf files.

Thanks

--
Rory



Aug 21 '08 #2
Hello Juan,
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
string extension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (extension == ".pdf")
{
//your upload code...
}
}
Thanks Juan. I already have something like that on the server-side.

I was hoping however to present the user of my site with a slightly friendlier
interface by masking out everything other than pdfs in the dialog itself.

Looking around the net it doesn't seem like it's possible though.

--
Rory
Aug 21 '08 #3
According to w3.org you could try the "accept" attribute :

http://www.w3.org/TR/html4/interact/...ml#adef-accept

that said I'm not sure this is widely supported...

--
Patrice

"Rory Becker" <ro********@newsgroup.nospama écrit dans le message de
groupe de discussion : 3a**************************@news.microsoft.com...
Hello Juan,
>if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
string extension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (extension == ".pdf")
{
//your upload code...
}
}

Thanks Juan. I already have something like that on the server-side.

I was hoping however to present the user of my site with a slightly
friendlier interface by masking out everything other than pdfs in the
dialog itself.

Looking around the net it doesn't seem like it's possible though.

--
Rory

Aug 21 '08 #4

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

Similar topics

2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
1
by: Marko Vuksanovic | last post by:
I am trying to implement an upload progress indicator using atlas, using the following workaround: http://forums.asp.net/thread/1321664.aspx This is the code in FileUpload.apsx file is as...
12
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
0
by: Christian Schlemmer | last post by:
If my code will run into the filesize-limit condition, the INSERT-statement will be executed. is there a way to avoid that? Protected Sub DetailsView1_RowInserting(ByVal sender As Object,...
4
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
5
by: =?Utf-8?B?QmVydA==?= | last post by:
Hi How can you set the filename property in the asp:fileupload control? How can you persist the value of the chosen filename between postbacks? thanks B
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers)...
14
by: Airtech | last post by:
I am using the AllenBrowne code of "filldirlisttotable" to provide some functions for a media library manager I am building in access 2003. I have four checkboxes which if all four are not turned...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.