C# & WebClient - POST/File upload problem

P

pmz

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
fails.

Source code looks so:

string RemotePath = string.Format("http://{0}/scripts/set-image.php",
ServerHostname);
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:

192.168.10.40 - - [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
 
P

pmz

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
future)

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 :cool:

Best regards,
Przemek M. Zawada
 

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