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?

ina
  • 19,167
  • 39
  • 122
  • 201
  • Wouldn't that be `name="file"`? That's what I'm getting. And if you're sending it to a PHP script multiple files, make sure the name ends in `[]`, as in `name="files[]"`. – Artefacto Jun 22 '10 at 00:25

2 Answers2

0

You could try UploadFileEx from CodeProject.

Don
  • 9,511
  • 4
  • 26
  • 25
0

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: Upload files with HTTPWebrequest (multipart/form-data)

Good luck to you :)

Community
  • 1
  • 1
regex
  • 3,585
  • 5
  • 31
  • 41
  • 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 Jun 22 '10 at 00:44