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.

Another File Upload question

Hi there,
I've been reading all I could find on the control 'input type=file' and all
the trouble that it comes when uploading large binary files (>4MB) to a DB
server or server path.

I've seen plenty of examples about it, and they all agree that to make
possible the upload of those files, it's mandatory to change the web.config
(or machine.config) for the maxRequestLength attribute of the <httpRuntime>
element.

What I'd need though, is a way for NOT allowing content larger than those
4MB to be uploaded. I've tryed the following on my code, but it's not
working (probably because I've also read that when submitting the webform,
the content is already sent to the server, thus if you send 50MB you'll have
to wait until the server returns an error)

if( FileInputAttachment.PostedFile.ContentLength ) > 1024
{
//change a label text to display an error
}

Is there a way of querying for the PostedFile.ContentLength BEFORE posting
the data to the server? This way I could warn the users not to upload files
larger than a MB or so...

Thanks!!
Nov 19 '05 #1
4 1215
Hi ricardo,

Wiothout some sort of ActiveX control or Java applet on the client side,
there is no way to determine the length of the file prior to upload. The
input only contains the path to the file to be uploaded on the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"ricardo corbacho perez" <ricardo corbacho pe***@discussions.microsoft.com>
wrote in message news:14**********************************@microsof t.com...
Hi there,
I've been reading all I could find on the control 'input type=file' and
all
the trouble that it comes when uploading large binary files (>4MB) to a DB
server or server path.

I've seen plenty of examples about it, and they all agree that to make
possible the upload of those files, it's mandatory to change the
web.config
(or machine.config) for the maxRequestLength attribute of the
<httpRuntime>
element.

What I'd need though, is a way for NOT allowing content larger than those
4MB to be uploaded. I've tryed the following on my code, but it's not
working (probably because I've also read that when submitting the webform,
the content is already sent to the server, thus if you send 50MB you'll
have
to wait until the server returns an error)

if( FileInputAttachment.PostedFile.ContentLength ) > 1024
{
//change a label text to display an error
}

Is there a way of querying for the PostedFile.ContentLength BEFORE posting
the data to the server? This way I could warn the users not to upload
files
larger than a MB or so...

Thanks!!

Nov 19 '05 #2
I feared so...Do you know of any third party (and hopefully free) ActiveX
control I could use?
"Kevin Spencer" wrote:
Hi ricardo,

Wiothout some sort of ActiveX control or Java applet on the client side,
there is no way to determine the length of the file prior to upload. The
input only contains the path to the file to be uploaded on the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"ricardo corbacho perez" <ricardo corbacho pe***@discussions.microsoft.com>
wrote in message news:14**********************************@microsof t.com...
Hi there,
I've been reading all I could find on the control 'input type=file' and
all
the trouble that it comes when uploading large binary files (>4MB) to a DB
server or server path.

I've seen plenty of examples about it, and they all agree that to make
possible the upload of those files, it's mandatory to change the
web.config
(or machine.config) for the maxRequestLength attribute of the
<httpRuntime>
element.

What I'd need though, is a way for NOT allowing content larger than those
4MB to be uploaded. I've tryed the following on my code, but it's not
working (probably because I've also read that when submitting the webform,
the content is already sent to the server, thus if you send 50MB you'll
have
to wait until the server returns an error)

if( FileInputAttachment.PostedFile.ContentLength ) > 1024
{
//change a label text to display an error
}

Is there a way of querying for the PostedFile.ContentLength BEFORE posting
the data to the server? This way I could warn the users not to upload
files
larger than a MB or so...

Thanks!!


Nov 19 '05 #3
Sorry ricardo. But Google it. You never know.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"ricardo corbacho perez" <ri******************@discussions.microsoft.com>
wrote in message news:42**********************************@microsof t.com...
I feared so...Do you know of any third party (and hopefully free) ActiveX
control I could use?
"Kevin Spencer" wrote:
Hi ricardo,

Wiothout some sort of ActiveX control or Java applet on the client side,
there is no way to determine the length of the file prior to upload. The
input only contains the path to the file to be uploaded on the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"ricardo corbacho perez" <ricardo corbacho
pe***@discussions.microsoft.com>
wrote in message
news:14**********************************@microsof t.com...
> Hi there,
> I've been reading all I could find on the control 'input type=file' and
> all
> the trouble that it comes when uploading large binary files (>4MB) to a
> DB
> server or server path.
>
> I've seen plenty of examples about it, and they all agree that to make
> possible the upload of those files, it's mandatory to change the
> web.config
> (or machine.config) for the maxRequestLength attribute of the
> <httpRuntime>
> element.
>
> What I'd need though, is a way for NOT allowing content larger than
> those
> 4MB to be uploaded. I've tryed the following on my code, but it's not
> working (probably because I've also read that when submitting the
> webform,
> the content is already sent to the server, thus if you send 50MB you'll
> have
> to wait until the server returns an error)
>
> if( FileInputAttachment.PostedFile.ContentLength ) > 1024
> {
> //change a label text to display an error
> }
>
> Is there a way of querying for the PostedFile.ContentLength BEFORE
> posting
> the data to the server? This way I could warn the users not to upload
> files
> larger than a MB or so...
>
> Thanks!!
>
>


Nov 19 '05 #4
ricardo corbacho perez wrote:
Hi there,
I've been reading all I could find on the control 'input type=file'
and all the trouble that it comes when uploading large binary files
(>4MB) to a DB server or server path.

I've seen plenty of examples about it, and they all agree that to
make possible the upload of those files, it's mandatory to change the
web.config (or machine.config) for the maxRequestLength attribute of
the <httpRuntime> element.

What I'd need though, is a way for NOT allowing content larger than
those 4MB to be uploaded. I've tryed the following on my code, but
it's not working (probably because I've also read that when
submitting the webform, the content is already sent to the server,
thus if you send 50MB you'll have to wait until the server returns an
error)

if( FileInputAttachment.PostedFile.ContentLength ) > 1024
{
//change a label text to display an error
}

Is there a way of querying for the PostedFile.ContentLength BEFORE
posting the data to the server? This way I could warn the users not
to upload files larger than a MB or so...


HTTP expectations (status code 100) are meant for that purpose,
although it still requires a (cheap) roundtrip. And it also requires
your web clients to play along nicely -- I have no idea if IE or
Firefox even use this header before posting (large) entities.
System.Net.HttpWebRequest does by default.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #5

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

Similar topics

13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
by: bala | last post by:
Hi All, Sorry for repost I have a popup for image upload with a upload button,save button and one close button I am uploading images with a file control after browsing when I click on upload...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
9
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that...
7
by: clintonG | last post by:
I'm puzzled and don't think this is possible but if an application that is running on websiteA generates a file can FTP be used from websiteA to transfer that file to websiteB which would be...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
by: lPrentice | last post by:
Hello, After all this time, Linux file permissions still confuse me at times. I have a Python web-based application with an file (images) upload module. The application is running on two remote...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.