我想用C#和WebClient類在特定網站上上傳文件。我有這樣的代碼:C#使用webclient更改內容處置
Console.Write("\nPlease enter the URI to post data to : ");
String uriString = "http://www.noelshack.com/api.php";
// String uriString = "http://127.0.0.1/upload.php";
WebClient myWebClient = new WebClient();
string fileName = lst_path[0];
byte[] responseArray = myWebClient.UploadFile(uriString,"POST", fileName);
MessageBox.Show("\nretour:" + System.Text.Encoding.ASCII.GetString(responseArray));
但問題,網站上的文件輸入的名稱是「fichier」和Web客戶端發送「文件」作爲名字。
我希望它發送:
內容處理:表格數據; NAME = 「fichier」; filename =「csharp.jpg」 而不是: Content-Disposition:form-data; NAME = 「文件」;文件名=「csharp.jpg」
我沒有找到如何修改此字段,有些幫助嗎?
反編譯'System.Net.WebClient.UploadFile',它使用'System.Net.WebClient。 OpenFileInternal',顯示'Content-Disposition:form-data; NAME = 「文件」;您需要使用其他方法 – cubetwo1729