471,330 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

C# & WebClient - POST/File upload problem

Dear Group,

I'm currently developing a simple Windows application in C#, which is
supposed to upload images - through 'WebClient' - into remote
(FreeBSD/Apache/PHP) server.

What is interesting (and the problem) that my script on the remote
server side says so: UPLOAD_ERR_PARTIAL (php error) - which means that
file was not successfuly (till the eof) uploaded. There is no
possibility of any limits (like php.ini - max_file_upload_size, and
so), so the server-side error case I dismiss. So probably my WebClient
is 'transmitting data' not good enough to the remote server. Anyhow, it

Source code looks so:

string RemotePath = string.Format("http://{0}/scripts/set-image.php",
WebClient InsertClient = new WebClient();
InsertClient.QueryString.Add("CD", "2efa6fd4087b6168a6c14ca1f10785e3");
byte[] Response = InsertClient.UploadFile( RemotePath, "POST", FilePath

Nothing seems to be wrong - not many lines to get any mistakes, but it
has failed anyhow.
A. FilePath - file exists, for sure and it's accessible.
B. Remote Server is also up and running, so ain't the problem.
C. Request size is interesting. As I followed Apache log file: - - [17/Jan/2006:07:54:56 +0100] "POST
/scripts/set-image.php?CD=2efa6fd4087b6168a6c14ca1f10785e3 HTTP/1.1"
200 18

18 is a little bit to small for such file (~200kb), isn't it?

If something I've written is not clear enough, please write it down,
I'll try to upgrade my problem with more data.

Anyway, please help.

Best regards,
Przemek M. Zawada

Jan 17 '06 #1
1 15101
Dear Group,

I'm really sorry for my unprofessional treatment in this case. I've
found sollution - it might be a little bit offtopic here, but... (for

The problem was in php.ini file on server-side. After notice in Apache
log: PHP Notice: Only 0 bytes were written, expected to write 5119 in
Unknown on line 0, I've found out, that something is not okay with
saving data from foreign source - because form's on local hosting,
works fine. So I've changed (set up) in php.ini variable called:
'upload_tmp_dir' to /tmp/up and chowned to Apache daemon this folder
with good rw rights.

Anyway, It's working and sorry for all this mess here 8-)

Best regards,
Przemek M. Zawada

Jan 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by kafooey | last post: by
reply views Thread by Felix Natter | last post: by
1 post views Thread by Muttly | last post: by
reply views Thread by Steve Morse | last post: by
4 posts views Thread by R Reyes | last post: by
4 posts views Thread by G0ng | last post: by
11 posts views Thread by callieandmark | last post: by
3 posts views Thread by dreamznatcher | last post: by
4 posts views Thread by Nelluru | last post: by
reply views Thread by rosydwin | last post: by

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.