473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C# & WebClient - POST/File upload problem

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

Jan 17 '06 #1
1 15408
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 8-)

Best regards,
Przemek M. Zawada

Jan 17 '06 #2

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

Similar topics

3
by: kafooey | last post by:
Hi all, I've been digging around on the newsgroups and the web for a possible answer for this problem, but have so far come up with nothing so thought I would ask here... I have the following...
0
by: Felix Natter | last post by:
hi, on our webserver both open_basedir and safe_mode are active, so I have to use move_uploaded_file(). But when I do this, the destination file is 0600 and uid/gid=www-data and due to...
1
by: Muttly | last post by:
Hey all. I'm trying to upload multiple files. I'm using the chm file from php.net to help me figure it out. I also checked online and say theres a problem with the file. Anyway My html looks like...
0
by: Steve Morse | last post by:
Our website has a form with a file upload control (<input type="file">). We are experiencing a problem when accessing this page from the clients web site from a safari browser. After selecting a...
4
by: R Reyes | last post by:
I am trying to code a file uploader (for forum/email attachments) from the client computer to a remote web server via the PUT method (since POST is not allowed ). However, the upload works ONLY...
4
by: G0ng | last post by:
Hello. I have a form with two input file fields for uploading file: <form name="mynews" action="news.php?action=update&add=<?php print $id;?>" method="post" enctype="multipart/form-data"> ...
11
by: callieandmark | last post by:
I have a very simple file upload script which creates a thumbnail of the file (jpg) upon uploading. This works fine with small images, however, if i try to upload a file over about 1mb the...
3
by: dreamznatcher | last post by:
Hello, I found a script here: http://www.webtoolkit.info/ajax-file-upload.html which supposedly allows you to upload files using AJAX (I'm not an expert). The site claims it's the best way to...
4
by: Nelluru | last post by:
hi all, My problem is that I want to upload a file without asking the user to select the file as I know the location of the file on the users machine. The whole process goes like this, ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.