C# & WebClient - POST/File upload problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pmz

    #1

    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_PART IAL (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.Qu eryString.Add(" CD", "2efa6fd4087b61 68a6c14ca1f1078 5e3");
    byte[] Response = InsertClient.Up loadFile( 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=2e fa6fd4087b6168a 6c14ca1f10785e3 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

  • pmz

    #2
    Re: C# & WebClient - POST/File upload problem

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

    Best regards,
    Przemek M. Zawada

    Comment

    Working...