我正在尝试通过 POST 将数据从我的 Windows 应用商店应用程序传输到我的网络服务器。我尝试了以下方法:
try
{
HttpClient httpClient = new HttpClient();
Stream stream = GenerateSampleStream(500);
StreamContent streamContent = new StreamContent(stream);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "address/script.php");
request.Content = streamContent;
request.Headers.TransferEncodingChunked = true; // Assume we do not know the content length
HttpResponseMessage response = await httpClient.SendAsync(request);
}
private static MemoryStream GenerateSampleStream(int size)
{
// Generate sample data.
byte[] subData = new byte[size];
for (int i = 0; i < subData.Length; i++)
{
subData[i] = 64; // '@'
}
return new MemoryStream(subData);
}
查看我的 script.php,我没有得到任何 POST 数据:
if($_POST) {
mail(...);
}