program we will see How to retrieve the properties of file uploaded by the user
We have already known how to
upload the file in the server, in this program we will see How to retrieve the
properties of file uploaded by the user.
We can retrieve some of
the interesting and useful properties of the file that is uploaded to the
webserver. The PostedFile provides us with three important properties, such as
FileName, ContentType and ContentLength. In our previous example, we already
saw, how to use the property, FileName? Now, we will see, how to know the size
of the file uploaded, and how to know the contentType of the file uploaded.
The following line of code
retrieves the ContentType of the file uploaded.
lblFileContentType.Text = MyFile.PostedFile.ContentType
The following line of code
retrieves the Size of the file uploaded.
lblFileSize.Text = CStr(MyFile.PostedFile.ContentLength)
Now, we will see an example which uses this property.
Example: Uploading a File in ASP .NET
<html>
|
How to control the size of file
uploaded to the web server?
While uploading a file to
the web server, we have a limit of 4MB by default. We can either decrease or
increase this value. The value is set in the key, maxRequestLength of machine
config file.
There is a maxRequestLength limit in the machine.config file (look for the
<system.web> section); in the http Runtime settings that you need to
alter/raise if you want to accept anything larger than 4Mb. These are the
standard settings for the httpRuntime:
<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"/>
0 comments:
Post a Comment