473,781 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebClient.Uploa dFile adds stuff to the file.

UJ
I'm trying to upload stuff using the UploadFile from WebClient and I've
noticed that it adds header and footers to the stream.

Is there any way to get rid of that automatically?

I'm using
webclient.Uploa dFile("http://127.0.0.1/ECSWebServices/UploadItem.aspx ",
"POST", "C:\Test.tx t")

and the file ends up looking like:

-----------------------8c8a61883d4721e
Content-Disposition: form-data; name="file"; filename="test2 .txt"
Content-Type: application/octet-stream

This is a test file.
-----------------------8c8a61883d4721e
How do I get rid of the header/footer?

TIA - Jeff.
Sep 14 '06 #1
2 3965
you can be sure that there is something going on in your UploadItem.aspx
page that is writing the header and footer.
the UploadFile method works as you would expect it to.

the sample code from the SDK is as follows:

void Page_Load(objec t sender, EventArgs e)
{
foreach(string f in Request.Files.A llKeys)
{
HttpPostedFile file = Request.Files[f];
file.SaveAs("c: \\inetpub\\test \\UploadedFiles \\" + file.FileName);
}}
what code are you using?
tim
"UJ" <fr**@nowhere.c omwrote in message
news:OT******** ******@TK2MSFTN GP03.phx.gbl...
I'm trying to upload stuff using the UploadFile from WebClient and I've
noticed that it adds header and footers to the stream.

Is there any way to get rid of that automatically?

I'm using
webclient.Uploa dFile("http://127.0.0.1/ECSWebServices/UploadItem.aspx ",
"POST", "C:\Test.tx t")

and the file ends up looking like:

-----------------------8c8a61883d4721e
Content-Disposition: form-data; name="file"; filename="test2 .txt"
Content-Type: application/octet-stream

This is a test file.
-----------------------8c8a61883d4721e
How do I get rid of the header/footer?

TIA - Jeff.


Sep 15 '06 #2
Thus wrote UJ,
I'm trying to upload stuff using the UploadFile from WebClient and
I've noticed that it adds header and footers to the stream.

Is there any way to get rid of that automatically?

I'm using
webclient.Uploa dFile("http://127.0.0.1/ECSWebServices/UploadItem.aspx "
, "POST", "C:\Test.tx t")

and the file ends up looking like:

-----------------------8c8a61883d4721e
Content-Disposition: form-data; name="file"; filename="test2 .txt"
Content-Type: application/octet-stream
This is a test file.
-----------------------8c8a61883d4721e
How do I get rid of the header/footer?

TIA - Jeff.
That's a multipart/form-data request and supposed to look like that.

Either use WebClient.Uploa dData() or make sure the server side knows how
to deal with a multipart/form-data request.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Sep 16 '06 #3

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

Similar topics

0
1480
by: David W | last post by:
I am trying to upload a file from a user's system to my web server. I found code using the WebClient.UploadFile method. However, the uploaded file is from the server's hard drive not the user's system. I don't want to use the input file method (as this will force the user to do unnessecary browsing and I know where the file will be: c:\test.txt for example). I am sure that I am just missing something simple. However, I can not figure...
0
1836
by: Saverio Tedeschi | last post by:
Hi all gurus, forgive me if I submit a 2nd post, but I'm no more able to see my question. So: I wrote an Win app with embedded FTP client (well, made some cut and paste from others' projects :-)) to receive and send files from within the app itself. Now the server I connect to (IIS 5, W2K Svr+SP4) from 1st Jan on will allow just http/https connection, so I can no longer use FTP. I've thought to use System.Net.WebClient class and...
2
2202
by: marfi95 | last post by:
Hello all. I'm not sure if this is the correct place to post this, but if not please let me know. This is my situation. I have a simple problem, but am having problems doing this. I'm basically trying to upload a file from my .net app running on my local pc to a unix webserver (running iplanet). Just upload and store the file, thats it. I'm using webclient.uploadfile on the client side. Since its an iplanet webserver, I cant use...
1
5243
by: Phillip N Rounds | last post by:
I'm having problems using the WebClient.UploadFile() command. I have MySender.ASPX which is supposed to upload two files to the server. There is also ConsumeFileUpload.aspx which is intended to handle receipt of the files. Pertinent code for each is below. When I run the process locally in debug mode, everything works great ( VS.NET 2003 , ASP 1.1 ). When I run locally on the server, everything works great. When I try to remotely...
2
2990
by: Daniel | last post by:
As you may have guessed I'm trying to upload a file to a php server using the WebClient.UploadFile function, however the function never returns. Instead it chews up memory (fairly slowly) until it eventually runs out of memory then throws an assert saying out of memory. The file is about 400kb, and the code is what you would expect. This is the function that never returns webClient.UploadFile( otherUrl, "POST", "UploadedScreenShot.jpg"...
3
4309
by: =?Utf-8?B?dmFzaW1v?= | last post by:
Have the following code: wkLocalPath = "C:\A\1.jpg" wkServerPath = "http://servername/dirname/1.jpg" wcClient.Credentials = New NetworkCredential("UID", "PW") wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath) File exists on C. Dir exist on server (ASPNET user and Admin user have full rights) (tried both) Created virtual for Dirname and gave it write access in properties) "POST" gives same results.
5
10744
by: Svinja | last post by:
Hi, i am using WebClient.UploadFile to upload a file on my web page, code: WebClient webClient = new WebClient(); webClient.Credentials = new NetworkCredential(userName, pass); webClient.UploadFile("http://www.etfos.hr/~dhuis/test.txt", @"c:\test.txt"); i get an error "The remote server returned an error: (404) FIle not found" my web page is http://www.etfos.hr/~dhuis permissions are all enabled i tried with httpwebrequest class and...
6
4927
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error and the file is copied from the server to the server, rather than from the web client to the server. Please help!!!
5
5014
by: benmess | last post by:
This code snippet works fine on a localhost because the file you upload resides on the host machine (where FileServer.aspx is a new page invoked from the UploadFile call) function UploadGeneralFile(ByVal sURL as string,ByVal sFilename As String) Dim client As New System.Net.WebClient Dim sHTTPURL As String Dim req As New Uri(sURL) Dim respponse As Byte() sHTTPURL = req.Scheme() & "://" &...
0
9636
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
9474
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,...
1
10075
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
9931
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...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
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();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.