我需要通过PHP文件上传文件的服务器,我已经得到了这样的信息:照片上传带有参数的PHP页面
请对呼叫:这些参数/uploadFiles.php :
- $ _ POST [ 'user_ID的']
- $ _FILES [ '形象']
所以,我的q uestion是“用参数$ _GET ['user_id']和$ _FILES ['image']”调用php的意思,我怎样才能成功地调用php。
我已经为其他的需求,成功地通过“POST”的方法,这样做对服务器的调用:
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", "");
当然,我做了很多研究发布前,尝试了很多解决方案从这里的主题: https://stackoverflow.com/search?q=wp7+photo+upload
非常感谢您的帮助。
更新:
我发现我需要的是模拟这种简单的HTML上传表单:当我运行这在Web浏览器中我得到upload.php的良好反响
<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>
,所以我只需要在WP7中模拟这种方式,我尝试了一切,我很绝望。
我用myToolkit这样的,但像当我使用Web客户端,restsharp,吊床一样的反应:
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);
我想你应该尝试搜索了如何使用Web客户端或HttpWebRequest的上传文件。一些来自SO的链接可能有助于:[这里](http://stackoverflow.com/questions/2360832/using-net-to-post-a-file-to-server-httpwebrequest-or-webclient)和[这里] (http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data) – 2012-05-05 13:13:55