473,756 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading files using WebClient

I am trying to run the following C# code:
----------------------------------------
String uriString = "http://10.1.1.100/images/";
WebClient myWebClient = new WebClient();
string fileName = "C:\\agoodfrien d.jpg";
byte[] responseArray = myWebClient.Upl oadFile
(uriString,"POS T",fileName) ;
----------------------------------------

But I get the following error:

Exception Details: System.Net.WebE xception: The remote
server returned an error: (405) Method Not Allowed.

Does anyone know why this happens?

I suspected it was a permission thing. I tried enabling
the directory to be written, but it didn't work.

Thanks in advance for the help
Nov 18 '05 #1
3 2397
the uriString you supply has to support file uploads. the one you supplied
did not.

did you write a page to receive the file, or install some file upload
support software on you web server?

-- bruce (sqlwork.com)
"Mariela" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
I am trying to run the following C# code:
----------------------------------------
String uriString = "http://10.1.1.100/images/";
WebClient myWebClient = new WebClient();
string fileName = "C:\\agoodfrien d.jpg";
byte[] responseArray = myWebClient.Upl oadFile
(uriString,"POS T",fileName) ;
----------------------------------------

But I get the following error:

Exception Details: System.Net.WebE xception: The remote
server returned an error: (405) Method Not Allowed.

Does anyone know why this happens?

I suspected it was a permission thing. I tried enabling
the directory to be written, but it didn't work.

Thanks in advance for the help

Nov 18 '05 #2
Are you attempting to upload files using the multipart/form-data encoding?
If so

1. Your client needs to send data using this protocol and format
2. The server needs to have something that supports this as well.

--
Shiv R. Kumar
http://www.matlus.com
Nov 18 '05 #3
Are you attempting to upload files using the multipart/form-data encoding?
If so

1. Your client needs to send data using this protocol and format
2. The server needs to have something that supports this as well.

--
Shiv R. Kumar
http://www.matlus.com
Nov 18 '05 #4

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

Similar topics

4
2303
by: brianinbox | last post by:
Hi, I've been trying to upload file using webclient.uploadfile method from my IIS webserver to an Apache webserver without any success. On the Apache server (server that receives the incoming file) I have a simple php script, getFile.php to receive the file. The script look like this: <?php $uploadDir = '/var/www/Incoming/'; $uploadFile = $uploadDir . $_FILES;
0
1578
by: ron | last post by:
is there a way to upload files with the webclient component ?? mywebclient.uploadfile ... simple uploads a file, but I can´t specify any form field like INPUT TYPE=FILE SIZE=40 NAME="FILE1 ..uploaddata ... does not work, because I cant build any working byte array does anyone have a working code for this?
2
17411
by: genc ymeri | last post by:
I'm uploading a text through http server but I keep getting the below error. Is the below error coming from my code or from the http server ???? Any help/tip will be very much appreciated. Thank You very much in advance. try { //create an instance of the WebClient. System.Net.WebClient MyClient = new System.Net.WebClient();
6
12247
by: genc ymeri | last post by:
Hi, We are struggeling to upload a file through a C# webClient into JBoss web server. Meanwhile we are able to upload a file from the webserver itself. The problem is only with C# webClient . The code is pretty simple. string uriString = saveTargetToAddress.Text; string postData = textOutput.Text; try
4
3876
by: marfi95 | last post by:
Hi all, I'm trying to do what I consider to be a fairly simple task, yet I'm having a heck of a time getting it to work. I'm trying to upload a file (without user intervention and a browser) from a vb.net client (using webclient or httpwebrequest) to a webserver running a cgi script to store it on the webserver. I'm not familiar with perl/cgi very well and am really struggling with it. I kind of got it to partially work with...
0
863
by: Giulio Simeone | last post by:
Browsing in the web I find a lot of articles that argue: "With ASP.NET 2.0. uploading files is pretty easy!". I spent on that problem last three days but didn't found my way through it. I have to develop a web page that uploads files from my computer to a remote server. I tried to do it in many different ways, the last one is: Dim c,s As String Dim v() As String
1
1749
by: neoret | last post by:
Hi there. I need to perform an upload of a document using HTTP post. This has to be done from my windows form using C#. My challenge is: 1: To send - the word document 2: To attach several variables to the same request 3: To handle the response. 4: To authenticate my request by adding a username and pasword.
8
1741
by: ThunderMusic | last post by:
Hi, I'm currently building a little web site for me and my friends where we would like to be able to post big files (10Mb to 250Mb approx.) Right now the ASP.Net UploadFile control can't do it as we are limited 1) by the MaxRequestLength (4Mb) and 2) with big files (such as 250Mb) the server crashes because it only uses memory to cache the upload... Is there an easy way to develop an HTTP Module to handle the upload (links, tutorials,...
0
1223
by: mivey4 | last post by:
I have been experimenting with sending and receiving files using the webClient class provided in .NET. (C#) I don't seem to have any problems downloading files from my test web server using the class but sending (uploading) files to the server doesn't seem to be working and I don't receive any errors to suggest there is a problem. WebClient wc = new WebClient(); byte results; string uri =...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.