I need to upload file the server via .php file, and i've got this information:
Make a call to the: /uploadFiles.php with these parameters:
- $_POST['user_id']
- $_FILES['image']
So, my question is what does "call php with parameters $_GET['user_id'] and $_FILES['image']" mean, and how do I make a call to php sucessfully.
I've already, for other needs, succesfully made call to the server via "POST" method, like this:
var client = WebClient();
client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);
client.Headers["Content-Type"] = "application/x-www-form-urlencoded";
client.Encoding = Encoding.UTF8;
string toSend = "http://example.com/submit.php?userid=10";
client.UploadStringAsync(new Uri(toSend), "POST", "");
Of course, I did much research before posting, tried a lot of solutions from topics here:
https://stackoverflow.com/search?q=wp7+photo+upload
Thank you in advance for your help.
Update:
I found out all i need is to simulate this SIMPLE HTML UPLOAD form:
<form method='POST' enctype='multipart/form-data' action='http:/myserver.com/upload.php'>
File to upload <input type=file name=image><br>
user_id <input type=text name=user_id><br>
<br>
<input type=submit value=Press> to upload the file!
</form>
When i run this in web browser i get good response from upload.php, so i just need the way to simulate this in WP7, i tried everything, i'm desperate.
I used myToolkit like this, but same response like when i used webclient, restsharp, hammock:
var request = new HttpPostRequest("http://myserver.com/upload.php");
request.Data.Add("user_id", "389096"); // POST data
request.Files.Add(new HttpPostFile("image", "", e.ChosenPhoto, true)); // POST file
Http.Post(request, RequestFinished);
See Question&Answers more detail:
os