473,395 Members | 1,668 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.

File upload problem with IIS 6.0

We've recently moved an application from a W2K server to a Windows 2003
server with IIS 6.0 and in the process managed to lose the ability to handle
file uploads. I've managed to identify that this is not specific to IIS 6.0
since we have another server that doesn't give me any problems in this
respect.

The test program below illustrates the problem. The Page_Load method never
resolves the IsPostBack property to true and the btnUpload_ServerClick event
never fires. When I change the web.config to enable trace in pageOutput
mode, it shows that a POST is in fact received. This test file runs fine
under any other server that I have tried it on (IIS5.0 IIS5.1 IIS6.0).

The server giving me trouble is a production server and has security policy
fairly well locked down. I couldn't identify anything in the policy that may
be causing this however.

Anyone got any clues?

Terry Field.

------- Test file starts here ----------------------------
<%@ Page language="c#" runat="server" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>FileUpload</title>
</head>
<body>

<script language="C#" runat="server">
void btnUpload_ServerClick(object sender, System.EventArgs e) {

if (fileUpload.PostedFile == null) {
Response.Write("No file specified");
return;
}

int len = (int) fileUpload.PostedFile.InputStream.Length;
if (len == 0) {
Response.Write("File is empty or failed to upload");
return;
}

byte[] data = new byte[len];
try {
fileUpload.PostedFile.InputStream.Read(data, 0, len);
}
catch {
Response.Write("Failed to read upload");
return;
}

if (data.Length == len) {
Response.Write("Load Succeeded(" + len.ToString() + " bytes)");
}
else {
Response.Write("Unknown error");
}
}

void Page_Load() {
if (IsPostBack)
Response.Write("<p>Current request is POST</p>");
else
Response.Write("<p>Current request is GET</p>");
}
</script>

<form id="fileUpLoadForm" method="post" enctype="multipart/form-data"
runat="server">
<input type="file" id="fileUpload" name="fileUpload" runat="server">
<br>
<input id="btnUpload" type="submit" value="Upload" runat="server"
name="btnUpload" onserverclick="btnUpload_ServerClick">
<br>
<span id="spanError" runat="server"></span>
</form>
</body>
</html>
Nov 18 '05 #1
2 7612
If I remember correctly, ASP.NET does not have write priveleges, by default,
on IIS 6.0. The ASPNET account needs the ability to write to the directory
in question.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Terry Field" <EmailAddressWithheld@ForFearOfBeingSpammed> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
We've recently moved an application from a W2K server to a Windows 2003
server with IIS 6.0 and in the process managed to lose the ability to handle file uploads. I've managed to identify that this is not specific to IIS 6.0 since we have another server that doesn't give me any problems in this
respect.

The test program below illustrates the problem. The Page_Load method never
resolves the IsPostBack property to true and the btnUpload_ServerClick event never fires. When I change the web.config to enable trace in pageOutput
mode, it shows that a POST is in fact received. This test file runs fine
under any other server that I have tried it on (IIS5.0 IIS5.1 IIS6.0).

The server giving me trouble is a production server and has security policy fairly well locked down. I couldn't identify anything in the policy that may be causing this however.

Anyone got any clues?

Terry Field.

------- Test file starts here ----------------------------
<%@ Page language="c#" runat="server" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>FileUpload</title>
</head>
<body>

<script language="C#" runat="server">
void btnUpload_ServerClick(object sender, System.EventArgs e) {

if (fileUpload.PostedFile == null) {
Response.Write("No file specified");
return;
}

int len = (int) fileUpload.PostedFile.InputStream.Length;
if (len == 0) {
Response.Write("File is empty or failed to upload");
return;
}

byte[] data = new byte[len];
try {
fileUpload.PostedFile.InputStream.Read(data, 0, len);
}
catch {
Response.Write("Failed to read upload");
return;
}

if (data.Length == len) {
Response.Write("Load Succeeded(" + len.ToString() + " bytes)");
}
else {
Response.Write("Unknown error");
}
}

void Page_Load() {
if (IsPostBack)
Response.Write("<p>Current request is POST</p>");
else
Response.Write("<p>Current request is GET</p>");
}
</script>

<form id="fileUpLoadForm" method="post" enctype="multipart/form-data"
runat="server">
<input type="file" id="fileUpload" name="fileUpload" runat="server">
<br>
<input id="btnUpload" type="submit" value="Upload" runat="server"
name="btnUpload" onserverclick="btnUpload_ServerClick">
<br>
<span id="spanError" runat="server"></span>
</form>
</body>
</html>

Nov 18 '05 #2
The test script below doesn't attempt to write any files to any directory.
This is not a file system permissions issue. That aspect has been
investigated thoroughly.

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM> wrote
in message news:es*************@TK2MSFTNGP11.phx.gbl...
If I remember correctly, ASP.NET does not have write priveleges, by default, on IIS 6.0. The ASPNET account needs the ability to write to the directory
in question.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Terry Field" <EmailAddressWithheld@ForFearOfBeingSpammed> wrote in message news:uf**************@tk2msftngp13.phx.gbl...
We've recently moved an application from a W2K server to a Windows 2003
server with IIS 6.0 and in the process managed to lose the ability to

handle
file uploads. I've managed to identify that this is not specific to IIS

6.0
since we have another server that doesn't give me any problems in this
respect.

The test program below illustrates the problem. The Page_Load method never resolves the IsPostBack property to true and the btnUpload_ServerClick

event
never fires. When I change the web.config to enable trace in pageOutput
mode, it shows that a POST is in fact received. This test file runs fine
under any other server that I have tried it on (IIS5.0 IIS5.1 IIS6.0).

The server giving me trouble is a production server and has security

policy
fairly well locked down. I couldn't identify anything in the policy that

may
be causing this however.

Anyone got any clues?

Terry Field.

------- Test file starts here ----------------------------
<%@ Page language="c#" runat="server" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>FileUpload</title>
</head>
<body>

<script language="C#" runat="server">
void btnUpload_ServerClick(object sender, System.EventArgs e) {

if (fileUpload.PostedFile == null) {
Response.Write("No file specified");
return;
}

int len = (int) fileUpload.PostedFile.InputStream.Length;
if (len == 0) {
Response.Write("File is empty or failed to upload");
return;
}

byte[] data = new byte[len];
try {
fileUpload.PostedFile.InputStream.Read(data, 0, len);
}
catch {
Response.Write("Failed to read upload");
return;
}

if (data.Length == len) {
Response.Write("Load Succeeded(" + len.ToString() + " bytes)");
}
else {
Response.Write("Unknown error");
}
}

void Page_Load() {
if (IsPostBack)
Response.Write("<p>Current request is POST</p>");
else
Response.Write("<p>Current request is GET</p>");
}
</script>

<form id="fileUpLoadForm" method="post" enctype="multipart/form-data" runat="server">
<input type="file" id="fileUpload" name="fileUpload" runat="server">
<br>
<input id="btnUpload" type="submit" value="Upload" runat="server"
name="btnUpload" onserverclick="btnUpload_ServerClick">
<br>
<span id="spanError" runat="server"></span>
</form>
</body>
</html>


Nov 18 '05 #3

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

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
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: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
1
by: DavidA | last post by:
I have a very simple form and perl script that is to upload a jpg file. I am not familiar with the perl language but copied the code from a text book. It works fine with all browsers except IE....
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"...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
3
by: shapper | last post by:
Hello, I need to upload a file. Can I only do this with the File Upload control? I also need the following: - Send upload info, upload percentage, continuously to a JavaScript function so...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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.