473,791 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebClient.Uploa dFile

As you may have guessed I'm trying to upload a file to a php server using the
WebClient.Uploa dFile 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.Uploa dFile( otherUrl, "POST", "UploadedScreen Shot.jpg" );

The URL looks like this (I can't actually give you the real one)

http://IP/Proxy.php?someparam=val&moreparams=val2

What I'm expecting is something like:
There is an incompatibility between php and .net versions blah, blah, but I
can't seem to find anything like that.

Sep 12 '06 #1
2 2990

Dunno how much use this will be but here's the php code which deals with the
file.

// save the file to a new location
$uploaddir = "./tempuploads/";
$uploadfile = $uploaddir . basename( $_FILES["file"]["tmp_name"] );
move_uploaded_f ile( $_FILES["file"]["tmp_name"], $uploadfile );

// load the file into the file structure

$readFile = fopen( $uploadfile, "rb" );
while ( feof( $readFile ) == false )
{
// read 2048 bytes at a time till we get to the end
// NOTE this number is just one I choose
// the number needs to be less then 8148 (I think)
// because thats the maximum limit of the fread function in PHP
$tempMem = $tempMem . fread( $readFile, 2048 );
}
fclose( $readFile );

Sep 12 '06 #2
As you may have guessed I'm trying to upload a file to a php server using the
WebClient.Uploa dFile 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.Uploa dFile( otherUrl, "POST", "UploadedScreen Shot.jpg" );

The URL looks like this (I can't actually give you the real one)

http://IP/Proxy.php?someparam=val&moreparams=val2

What I'm expecting is something like:
There is an incompatibility between php and .net versions blah, blah, but I
can't seem to find anything like that.
I have aproximatively the same problem with WebClient.Uploa dFile method.
I've build a service that basically has to upload some files to a Http server.
Problem is if the file has 200MB for ex. it will eat up ~200MB of memory while uploading, and.....after upload is finished, memory remains aloccated.
Of course, you can imagine what happens if i try to upload several big files...

I've tried Dispose() - doesn't work
I've tried async call - doesn't work
Posted from http://www.topxml.com/renntp using reNNTP: the website based NNTP reader.
Oct 18 '06 #3

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

Similar topics

0
1600
by: belfast neil | last post by:
Hey guys, I've seen alot of questions out there about webclient.uploadfile, my question is slightly different.......... I have a rich client app and I want to upload files to a server. Looking through the documentation(ha) I noticed that webclient.uploadfile seemed to be the way forward. Although I can't find anything to tell me how I actually receive it.
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
1837
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...
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...
5
4682
by: linn | last post by:
The 'Address' parameter in the WebClient.UploadFile usually comes in the form of ie. http://server/Upload_File.aspx Hence my question, what is exactly the content of this Upload_File.aspx? Am i supposed to create this file with some specific codes? Can't seems to get this method working for me in framework 2.0.. Thanks for any help.
2
3967
by: UJ | last post by:
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.UploadFile("http://127.0.0.1/ECSWebServices/UploadItem.aspx", "POST", "C:\Test.txt") and the file ends up looking like:
0
768
by: Mihaly | last post by:
I have a WinForms 1.1 application and I want to post some files on the webserver, using WebClient.UploadFile() method. I try the solution from MSDN site - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetWebClientClassUploadFileTopic1.asp. I creat a ReciveFile.aspx webpage with the content dercribed on this site and I use send the file with this code: WebClient web = new WebClient();...
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
4929
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
9515
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
10426
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
10207
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...
0
9029
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...
1
7537
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
6776
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
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.