Home All Groups Group Topic Archive Search About

FileUpload control - file size detection

Author
7 Nov 2006 7:37 PM
E. Kwong
Is it possible to obtain the file size at the moment when the file path/name
populates the textbox portion of the FileUpload control?

Thx

Author
7 Nov 2006 9:51 PM
Brennan Stehling
The HTML markup to do file upload is the INPUT element with "file" set
as the TYPE.  You can read the specifications on it here.

http://www.w3.org/TR/html4/interact/forms.html

Unfortunately it does not support a file size limit with an attribute
on that markup element.  That would be an obvious feature, but perhaps
it is not allowed due to security concerns although the size should be
a safe value to expose to an untrusted website.  This is touchy because
it is one of the few features of a web browser which gives you access
to the user's file system.

I just browsed a site I use which has an upload features and used
Firefox's Firebug add-on to browse the DOM for the upload form and it
did not show the size of the file I had selected.

If there is a way to limit file size for uploads I would also like to
know it.

Brennan Stehling
http://brennan.offwhite.net/blog/

E. Kwong wrote:
Show quoteHide quote
> Is it possible to obtain the file size at the moment when the file path/name
> populates the textbox portion of the FileUpload control?
>
> Thx
Author
8 Nov 2006 2:45 PM
Michael D. Ober
If you have access to the web-site's configuration file, you can limit the
upload size via the Web.config file as follows:

<system.web>
   <httpRuntime maxRequestLength="<max size in KB>"/>
</system.web>

Mike Ober.



Show quoteHide quote
"Brennan Stehling" <offwh***@gmail.com> wrote in message
news:1162936291.885855.65240@i42g2000cwa.googlegroups.com...
> The HTML markup to do file upload is the INPUT element with "file" set
> as the TYPE.  You can read the specifications on it here.
>
> http://www.w3.org/TR/html4/interact/forms.html
>
> Unfortunately it does not support a file size limit with an attribute
> on that markup element.  That would be an obvious feature, but perhaps
> it is not allowed due to security concerns although the size should be
> a safe value to expose to an untrusted website.  This is touchy because
> it is one of the few features of a web browser which gives you access
> to the user's file system.
>
> I just browsed a site I use which has an upload features and used
> Firefox's Firebug add-on to browse the DOM for the upload form and it
> did not show the size of the file I had selected.
>
> If there is a way to limit file size for uploads I would also like to
> know it.
>
> Brennan Stehling
> http://brennan.offwhite.net/blog/
>
> E. Kwong wrote:
>> Is it possible to obtain the file size at the moment when the file
>> path/name
>> populates the textbox portion of the FileUpload control?
>>
>> Thx
>
Author
8 Nov 2006 6:48 PM
Steve C. Orr [MVP, MCSD]
That works but not at the moment the filename is put in the upload box as
the original poster requested.

I don't know of any way to meet that requirement other than a thick client
such as a windows forms component (with the appropriate permissions) or an
ActiveX control.

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net



Show quoteHide quote
"Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
news:uzh5JS0AHHA.3316@TK2MSFTNGP02.phx.gbl...
> If you have access to the web-site's configuration file, you can limit the
> upload size via the Web.config file as follows:
>
> <system.web>
>   <httpRuntime maxRequestLength="<max size in KB>"/>
> </system.web>
>
> Mike Ober.
>
>
>
> "Brennan Stehling" <offwh***@gmail.com> wrote in message
> news:1162936291.885855.65240@i42g2000cwa.googlegroups.com...
>> The HTML markup to do file upload is the INPUT element with "file" set
>> as the TYPE.  You can read the specifications on it here.
>>
>> http://www.w3.org/TR/html4/interact/forms.html
>>
>> Unfortunately it does not support a file size limit with an attribute
>> on that markup element.  That would be an obvious feature, but perhaps
>> it is not allowed due to security concerns although the size should be
>> a safe value to expose to an untrusted website.  This is touchy because
>> it is one of the few features of a web browser which gives you access
>> to the user's file system.
>>
>> I just browsed a site I use which has an upload features and used
>> Firefox's Firebug add-on to browse the DOM for the upload form and it
>> did not show the size of the file I had selected.
>>
>> If there is a way to limit file size for uploads I would also like to
>> know it.
>>
>> Brennan Stehling
>> http://brennan.offwhite.net/blog/
>>
>> E. Kwong wrote:
>>> Is it possible to obtain the file size at the moment when the file
>>> path/name
>>> populates the textbox portion of the FileUpload control?
>>>
>>> Thx
>>
>
>
Author
8 Nov 2006 8:33 PM
Michael D. Ober
Agreed - it doesn't answer OPs original question, but it can at least block
arbitrarily large files from being uploaded, which I suspect was the intent.

Mike.

Show quoteHide quote
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OhwCwZ2AHHA.1012@TK2MSFTNGP04.phx.gbl...
> That works but not at the moment the filename is put in the upload box as
> the original poster requested.
>
> I don't know of any way to meet that requirement other than a thick client
> such as a windows forms component (with the appropriate permissions) or an
> ActiveX control.
>
> --
> I hope this helps,
> Steve C. Orr
> MCSD, MVP, CSM
> http://SteveOrr.net
>
>
>
> "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
> news:uzh5JS0AHHA.3316@TK2MSFTNGP02.phx.gbl...
>> If you have access to the web-site's configuration file, you can limit
>> the upload size via the Web.config file as follows:
>>
>> <system.web>
>>   <httpRuntime maxRequestLength="<max size in KB>"/>
>> </system.web>
>>
>> Mike Ober.
>>
>>
>>
>> "Brennan Stehling" <offwh***@gmail.com> wrote in message
>> news:1162936291.885855.65240@i42g2000cwa.googlegroups.com...
>>> The HTML markup to do file upload is the INPUT element with "file" set
>>> as the TYPE.  You can read the specifications on it here.
>>>
>>> http://www.w3.org/TR/html4/interact/forms.html
>>>
>>> Unfortunately it does not support a file size limit with an attribute
>>> on that markup element.  That would be an obvious feature, but perhaps
>>> it is not allowed due to security concerns although the size should be
>>> a safe value to expose to an untrusted website.  This is touchy because
>>> it is one of the few features of a web browser which gives you access
>>> to the user's file system.
>>>
>>> I just browsed a site I use which has an upload features and used
>>> Firefox's Firebug add-on to browse the DOM for the upload form and it
>>> did not show the size of the file I had selected.
>>>
>>> If there is a way to limit file size for uploads I would also like to
>>> know it.
>>>
>>> Brennan Stehling
>>> http://brennan.offwhite.net/blog/
>>>
>>> E. Kwong wrote:
>>>> Is it possible to obtain the file size at the moment when the file
>>>> path/name
>>>> populates the textbox portion of the FileUpload control?
>>>>
>>>> Thx
>>>
>>
>>
>
>
Author
10 Nov 2006 3:46 PM
Brennan Stehling
This would be an ideal space for a Click-Once application which uploads
files using a desktop application.  It could connect to a web service
and send 1000kb chunks and monitor the progress for the user.  It could
even support a stop and resume process.

Such functionality is strongly lacking from the web browsers.

http://search.msdn.microsoft.com/search/Redirect.aspx?title=ClickOnce+Deployment+Overview+&url=http://msdn2.microsoft.com/en-us/library/142dbbz4.aspx

Brennan Stehling
http://brennan.offwhite.net/blog/

Michael D. Ober wrote:
Show quoteHide quote
> Agreed - it doesn't answer OPs original question, but it can at least block
> arbitrarily large files from being uploaded, which I suspect was the intent.
>
> Mike.
>
> "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
> news:OhwCwZ2AHHA.1012@TK2MSFTNGP04.phx.gbl...
> > That works but not at the moment the filename is put in the upload box as
> > the original poster requested.
> >
> > I don't know of any way to meet that requirement other than a thick client
> > such as a windows forms component (with the appropriate permissions) or an
> > ActiveX control.
> >
> > --
> > I hope this helps,
> > Steve C. Orr
> > MCSD, MVP, CSM
> > http://SteveOrr.net
> >
> >
> >
> > "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
> > news:uzh5JS0AHHA.3316@TK2MSFTNGP02.phx.gbl...
> >> If you have access to the web-site's configuration file, you can limit
> >> the upload size via the Web.config file as follows:
> >>
> >> <system.web>
> >>   <httpRuntime maxRequestLength="<max size in KB>"/>
> >> </system.web>
> >>
> >> Mike Ober.
> >>
> >>
> >>
> >> "Brennan Stehling" <offwh***@gmail.com> wrote in message
> >> news:1162936291.885855.65240@i42g2000cwa.googlegroups.com...
> >>> The HTML markup to do file upload is the INPUT element with "file" set
> >>> as the TYPE.  You can read the specifications on it here.
> >>>
> >>> http://www.w3.org/TR/html4/interact/forms.html
> >>>
> >>> Unfortunately it does not support a file size limit with an attribute
> >>> on that markup element.  That would be an obvious feature, but perhaps
> >>> it is not allowed due to security concerns although the size should be
> >>> a safe value to expose to an untrusted website.  This is touchy because
> >>> it is one of the few features of a web browser which gives you access
> >>> to the user's file system.
> >>>
> >>> I just browsed a site I use which has an upload features and used
> >>> Firefox's Firebug add-on to browse the DOM for the upload form and it
> >>> did not show the size of the file I had selected.
> >>>
> >>> If there is a way to limit file size for uploads I would also like to
> >>> know it.
> >>>
> >>> Brennan Stehling
> >>> http://brennan.offwhite.net/blog/
> >>>
> >>> E. Kwong wrote:
> >>>> Is it possible to obtain the file size at the moment when the file
> >>>> path/name
> >>>> populates the textbox portion of the FileUpload control?
> >>>>
> >>>> Thx
> >>>
> >>
> >>
> >
> >
Author
16 Nov 2006 2:54 AM
Steve C. Orr [MVP, MCSD]
Yes I've thought about that but security is the main problem.
By default click once applications don't have much access to the user's hard
drive.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


Show quoteHide quote
"Brennan Stehling" <offwh***@gmail.com> wrote in message
news:1163173614.588361.189770@h54g2000cwb.googlegroups.com...
> This would be an ideal space for a Click-Once application which uploads
> files using a desktop application.  It could connect to a web service
> and send 1000kb chunks and monitor the progress for the user.  It could
> even support a stop and resume process.
>
> Such functionality is strongly lacking from the web browsers.
>
> http://search.msdn.microsoft.com/search/Redirect.aspx?title=ClickOnce+Deployment+Overview+&url=http://msdn2.microsoft.com/en-us/library/142dbbz4.aspx
>
> Brennan Stehling
> http://brennan.offwhite.net/blog/
>
> Michael D. Ober wrote:
>> Agreed - it doesn't answer OPs original question, but it can at least
>> block
>> arbitrarily large files from being uploaded, which I suspect was the
>> intent.
>>
>> Mike.
>>
>> "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
>> news:OhwCwZ2AHHA.1012@TK2MSFTNGP04.phx.gbl...
>> > That works but not at the moment the filename is put in the upload box
>> > as
>> > the original poster requested.
>> >
>> > I don't know of any way to meet that requirement other than a thick
>> > client
>> > such as a windows forms component (with the appropriate permissions) or
>> > an
>> > ActiveX control.
>> >
>> > --
>> > I hope this helps,
>> > Steve C. Orr
>> > MCSD, MVP, CSM
>> > http://SteveOrr.net
>> >
>> >
>> >
>> > "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
>> > news:uzh5JS0AHHA.3316@TK2MSFTNGP02.phx.gbl...
>> >> If you have access to the web-site's configuration file, you can limit
>> >> the upload size via the Web.config file as follows:
>> >>
>> >> <system.web>
>> >>   <httpRuntime maxRequestLength="<max size in KB>"/>
>> >> </system.web>
>> >>
>> >> Mike Ober.
>> >>
>> >>
>> >>
>> >> "Brennan Stehling" <offwh***@gmail.com> wrote in message
>> >> news:1162936291.885855.65240@i42g2000cwa.googlegroups.com...
>> >>> The HTML markup to do file upload is the INPUT element with "file"
>> >>> set
>> >>> as the TYPE.  You can read the specifications on it here.
>> >>>
>> >>> http://www.w3.org/TR/html4/interact/forms.html
>> >>>
>> >>> Unfortunately it does not support a file size limit with an attribute
>> >>> on that markup element.  That would be an obvious feature, but
>> >>> perhaps
>> >>> it is not allowed due to security concerns although the size should
>> >>> be
>> >>> a safe value to expose to an untrusted website.  This is touchy
>> >>> because
>> >>> it is one of the few features of a web browser which gives you access
>> >>> to the user's file system.
>> >>>
>> >>> I just browsed a site I use which has an upload features and used
>> >>> Firefox's Firebug add-on to browse the DOM for the upload form and it
>> >>> did not show the size of the file I had selected.
>> >>>
>> >>> If there is a way to limit file size for uploads I would also like to
>> >>> know it.
>> >>>
>> >>> Brennan Stehling
>> >>> http://brennan.offwhite.net/blog/
>> >>>
>> >>> E. Kwong wrote:
>> >>>> Is it possible to obtain the file size at the moment when the file
>> >>>> path/name
>> >>>> populates the textbox portion of the FileUpload control?
>> >>>>
>> >>>> Thx
>> >>>
>> >>
>> >>
>> >
>> >
>