简体   繁体   English

WebClient上传文件并发布变量

[英]WebClient Upload file with variables posted

I am using the code below to upload a file to a remote php page. 我正在使用下面的代码将文件上传到远程php页面。 I would like to post an additional variable to verify the identity of the system uploading the file. 我想发布一个附加变量来验证上传文件的系统的身份。 Is there any way to add a header to the WebClient UploadFile that would allow the receiving script to have access to a posted variable? 有什么方法可以将标题添加到WebClient UploadFile中,以使接收脚本可以访问已发布的变量吗?

WebClient webClient = new WebClient();
webClient.UploadFileAsync(new Uri(HTTP_VERSIONCTRL_URL), fileloc);
webClient.UploadProgressChanged += OnProgress;

you can add a header like this 您可以添加这样的标题

webClient.Headers.Add("OurSecurityHeader", "encryptedvalue");

On the php side, you can use this to read headers: 在php端,您可以使用它来读取标头:

How do I read any request header in PHP 如何在PHP中读取任何请求标头

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM