views:

33

answers:

2

What is the best way for a C# .exe program, to upload to a php server script that accepts file uploads.

If using .NET WebClient is the only way, is there a way for WebClient to specify the parameter name, rather than just the file?

For example, the C# .exe would do basically what a simple html form would do in this case.

<input name="filename" type="file" />

How do you specify this name parameter using WebClient?

A: 

You could try UploadFileEx from CodeProject.

Don
+1  A: 

You can acheive this with the HttpWebRequest class. It's a bit tricky since you will most likely need to upload the file using MIME multipart formatting. However, this post explains this process much better than I can: http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data

Good luck to you :)

regex
From that same post, check out this guy's blog: http://aspnetupload.com/Upload-File-POST-HttpWebRequest-WebClient-RFC-1867.aspx.Looks like his UploadHelper class has the code built for doing this procedure already.
regex