0

I am currently working on a fileUploader in the C# language for a image hosting site I develop for, I am currently wondering what the best approach is to uploading files to the server(all php/sql) with the client software being C#.

Also, how would I process these uploads in a PHP script, would you say something along the lines of:

upload.php?appfile=filepath?

Thanks,

1 Answer 1

5

You can use the WebClient Class and its UploadFile Method:

using (var wc = new WebClient())
{
    wc.UploadFile("http://www.example.com/upload.php", "somefile.dat");
}

The UploadFile Method uses the POST method to upload the file to the HTTP resource; you need to set up your PHP script accordingly.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello there, thank you for that! Considering it uses POST, what will it post as? Regards
The method uploads the files in "multipart/form-data" format. You should be able to access them using $_FILES; see POST method uploads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.