[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Change "File of Type" in the Browse File dialog box.

=?Utf-8?B?cm9kY2hhcg==?=

2/6/2004 10:21:00 AM

Hi all,

I was wondering if it is possible to change or default the type of file the "Browse File" dialog box. Coz' I want to limit the type of files my user can upload.

Thanks.

Regards,
Jen
4 Answers

Alessandro Zifiglio

2/6/2004 1:38:00 PM

0

when using the HtmlInputFile control check its postedFile propertys
ContentType attribute. Check this against a predefined set of values, and if
the check pases then upload the file to the server otherwise display an
error to the user stating the file type is not supported etc ;P


if File1.PostedFile.ContentType = "US-ASCII" then
'take action
end if

"Jen" <anonymous@discussions.microsoft.com> wrote in message
news:2AD0546B-56EA-48CC-833B-149B9491B221@microsoft.com...
> Hi all,
>
> I was wondering if it is possible to change or default the type of file
the "Browse File" dialog box. Coz' I want to limit the type of files my
user can upload.
>
> Thanks.
>
> Regards,
> Jen


Alessandro Zifiglio

2/6/2004 7:37:00 PM

0

oops, this is not what you asked for. Yes you can limit the files in the
file open dialogbox.

here try this :

Public Class MyUrlEditor : Inherits FileNameEditor
Protected Overrides Sub InitializeDialog(ByVal openFileDialog As
OpenFileDialog)
openFileDialog.Filter =
"(*.JPG;*.JPEG;*.GIF;*.PNG)|*.JPG;*.JPEG;*.GIF;*.PNG|All files (*.*)|*.*"
End Sub

"Alessandro Zifiglio" <alessandrozifiglio@NO-SPAM-hotmail.com> wrote in
message news:WRMUb.4187$HO2.3543@news.edisontel.com...
> when using the HtmlInputFile control check its postedFile propertys
> ContentType attribute. Check this against a predefined set of values, and
if
> the check pases then upload the file to the server otherwise display an
> error to the user stating the file type is not supported etc ;P
>
>
> if File1.PostedFile.ContentType = "US-ASCII" then
> 'take action
> end if
>
> "Jen" <anonymous@discussions.microsoft.com> wrote in message
> news:2AD0546B-56EA-48CC-833B-149B9491B221@microsoft.com...
> > Hi all,
> >
> > I was wondering if it is possible to change or default the type of file
> the "Browse File" dialog box. Coz' I want to limit the type of files my
> user can upload.
> >
> > Thanks.
> >
> > Regards,
> > Jen
>
>


Jen

2/12/2004 3:26:00 AM

0

Hi Alessandro,

Thank you for your help. But I am a newbie in aspnet and C#. Pardon me, if I sound silly.
First of all, my development environment is asp.net for web. The codes you provide me with seems to be meant for window base (I really don't know how to apply it). Therefore, I didn't manage to get it working. I am using "file field" with the default "browse" button.

Regards,
Je


Alessandro Zifiglio

2/12/2004 10:06:00 AM

0

Jen, much clearer now. You cannot control through server side code, you can
check what files are being uploaded and limit option to disallow this with
an error message showing wrong file name. But this is not what you want.
What your saying is you want to filter out file types for you input file
element. This is possible by using the accept attribute for your input file
element and supplying it a list of files you want to accept.
Sample :
<input type="file" name="uploaded_file" accept="image/png, image/gif" />

Examples of content types include "text/html", "image/png", "image/gif",
"video/mpeg", "audio/basic", "text/tcl", "text/javascript", and
"text/vbscript". For the current list of registered Multipurpose Internet
Mail Extensions (MIME) types, see
http://www.w3.org/TR/1998/REC-html40-19980424/references.html#ref...

On a side note : Always use the enctype of "multi-part/form-data" on the
form, otherwise the files will not upload correctly

"Jen" <freesiajen@hotmail.com> wrote in message
news:E7A05725-9F44-4E34-96A4-6CE14E8239B9@microsoft.com...
> Hi Alessandro,
>
> Thank you for your help. But I am a newbie in aspnet and C#. Pardon me,
if I sound silly.
> First of all, my development environment is asp.net for web. The codes
you provide me with seems to be meant for window base (I really don't know
how to apply it). Therefore, I didn't manage to get it working. I am using
"file field" with the default "browse" button.
>
> Regards,
> Jen
>
>