473,398 Members | 2,393 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,398 software developers and data experts.

Uploading files using ASP.NET problem

Hello,

I have the following Html form:

<form name="submitForProcess"
action="http://localhost/xml/process.aspx" method="post"
enctype="multipart/form-data">

<input type="text" name="customerId" value="5" /><br />
<input type="text" name="customerName" value="Johnson" /><br />
<input type="file" name="customerPhoto"><br />

<input type="submit" value="OK" />

</form>
In the ASP.NET page which is supposed to process this request I can
get the uploaded file name, length and content using the Request.Files
collection. Using the Request.Form collection I can get the
"customerId" and "customerName" parameters with their values.

My problem is that I cannot get the name attribute of my input file
tag which in this case is "customerPhoto". The Request.Form collection
doesn't contain this parameter. I am desperate, please help me, is it
possible to get this value using .NET classes ?
Here is the the dialog between the client and the server:
---------------------------------------------------------------------------
POST /xml/process.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*
Accept-Language: fr
Content-Type: multipart/form-data;
boundary=---------------------------7d4ea18310688
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 1.1.4322)
Host: localhost
Content-Length: 1067
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASP.NET_SessionId=iwqfb3ju33u05cfx5jfajsys

-----------------------------7d4ea18310688
Content-Disposition: form-data; name="customerId"

5
-----------------------------7d4ea18310688
Content-Disposition: form-data; name="customerName"

Johnson
-----------------------------7d4ea18310688
Content-Disposition: form-data; name="customerPhoto";
filename="C:\Inetpub\wwwroot\xml\config.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<parameters>
<BizTalkListenLocationParameter>BizTalkListenLocat ion</BizTalkListenLocationParameter>
<MainNamespaceParameter>xmlns</MainNamespaceParameter>
</parameters>
<options>
<Debug>True</Debug>
</options>

<!--
Following are the network credential attributes for the
BizTalkListenerLocation application

If they are not explicitly set then the application
will use the currently connected user credentials.
-->

<credentials>
<Username></Username>
<Password></Password>
<Domain></Domain>
</credentials>

</configuration>
-----------------------------7d4ea18310688--
Nov 18 '05 #1
3 1436
Hi,
My problem is that I cannot get the name attribute of my
input file tag which in this case is "customerPhoto".


Put this in your codebehind:

protected System.Web.UI.HtmlControls.HtmlInputFile customerPhoto;

when the user uploads a file, you can use this to get the name:

customerPhoto.PostedFile.FileName

Beware: it will return the full name on the client computer. You should use
Path.GetFileName(customerPhoto.PostedFile.FileName ) to extract only the
filename.

Steven

- - -
Nov 18 '05 #2

"darin dimitrov" <da************@hotmail.com> wrote in message news:2b*************************@posting.google.co m...
Hello,

I have the following Html form:

<form name="submitForProcess"
action="http://localhost/xml/process.aspx" method="post"
enctype="multipart/form-data">

<input type="text" name="customerId" value="5" /><br />
<input type="text" name="customerName" value="Johnson" /><br />
<input type="file" name="customerPhoto"><br />

<input type="submit" value="OK" />

</form>
In the ASP.NET page which is supposed to process this request I can
get the uploaded file name, length and content using the Request.Files
collection. Using the Request.Form collection I can get the
"customerId" and "customerName" parameters with their values.

My problem is that I cannot get the name attribute of my input file
tag which in this case is "customerPhoto". The Request.Form collection
doesn't contain this parameter. I am desperate, please help me, is it
possible to get this value using .NET classes ?


see the Request.Files collection

Hans Kesting
Nov 18 '05 #3
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message news:<#G*************@tk2msftngp13.phx.gbl>...
"darin dimitrov" <da************@hotmail.com> wrote in message news:2b*************************@posting.google.co m...
Hello,

I have the following Html form:

<form name="submitForProcess"
action="http://localhost/xml/process.aspx" method="post"
enctype="multipart/form-data">

<input type="text" name="customerId" value="5" /><br />
<input type="text" name="customerName" value="Johnson" /><br />
<input type="file" name="customerPhoto"><br />

<input type="submit" value="OK" />

</form>
In the ASP.NET page which is supposed to process this request I can
get the uploaded file name, length and content using the Request.Files
collection. Using the Request.Form collection I can get the
"customerId" and "customerName" parameters with their values.

My problem is that I cannot get the name attribute of my input file
tag which in this case is "customerPhoto". The Request.Form collection
doesn't contain this parameter. I am desperate, please help me, is it
possible to get this value using .NET classes ?


see the Request.Files collection

Hans Kesting


Thanks very much for your post Hans,

I used the Request.Files.GetKey method to obtain the name of the attribute
Nov 18 '05 #4

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

Similar topics

4
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP...
5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
4
by: ayanwen | last post by:
I have problem in uploading files using ASP, can you give me some sample code about uploading using ASP? -- ayanwen ------------------------------------------------------------------------...
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...
4
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the...
1
by: wenqiang7 | last post by:
I am encountering a very strang problem with file uploading in my ASP.Net page. When we try to upload certain file, we'll get an error msg of "Cannot find server or DNS Error". We are running...
7
by: jambroo | last post by:
Hello, We are currently having issues uploading files using PHP. It seems files below 8MB are uploaded fine, however files above 8.2MB cause the page to timeout or show a 'Cannot find server or...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
2
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the...
0
by: LoriFranklin | last post by:
I'm a bit of a newbie here. I've learned a lot from reading the posts you all have here. I need some help uploading files using an asp form. I am using some code that I found from Jacob at...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.