簡體   English   中英

使用參數將照片上傳到PHP頁面

[英]Photo upload with parameters to a PHP page

我需要通過.php文件上傳文件服務器,我有這個信息:

使用以下參數調用:/uploadFiles.php:

  • $ _ POST [ 'user_id說明']
  • $ _FILES [ '圖像']

所以,我的問題是“使用參數$ _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 UPLOAD表單:

<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>

當我在網絡瀏覽器中運行時,我從upload.php得到了很好的響應,所以我只需要在WP7中模擬這個,我嘗試了一切,我很絕望。

我像這樣使用myToolkit ,但是當我使用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);

我想到了。 我發送了不正確的FilyType參數。 我發送的是image / jpg,image / jpeg,image / png,但是在模擬HTML上傳表單時,我們必須發送“image / pjpeg”。

我詳細解釋了這里(我使用的是RestSharp): http ://nediml.wordpress.com/2012/05/10/uploading-files-to-remote-server-with-multiple-parameters/#more-234

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM