error 403 - forbidden

G

Guest

Im trying to upload a file to a iis server.
But im always getting an error.
Can u help me, looking at my code or giving some tips?
I saw another post with prob related to httpwebrequest, it seems it worked for them...
But it seems luck doesnt want anything with me :)

Thx in advance


public void UploadFileBinary(string localFile, string uploadUrl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);


req.Method = "PUT";
req.AllowWriteStreamBuffering = true;

// Retrieve request stream
Stream reqStream = req.GetRequestStream();
StreamWriter wrtr = new StreamWriter(reqStream);

// Open the local file
FileStream rdr = new FileStream(localFile, FileMode.Open);

// Allocate byte buffer to hold file contents
byte[] inData = new byte[4096];

// loop through the local file reading each data block
// and writing to the request stream buffer
int bytesRead = rdr.Read(inData, 0, inData.Length);
while (bytesRead > 0)
{
reqStream.Write(inData, 0, bytesRead);
bytesRead = rdr.Read(inData, 0, inData.Length);
}

rdr.Close();
wrtr.Close();
reqStream.Close();

req.GetResponse();
}
 
C

Chris Tacke, eMVP

First, keep with the old thread rather than starting another.

Second, does IIS have permission to write to the directory?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top