相当于PHP的函数UploadData

时间:2013-06-25 18:29:09

标签: c# php upload

我在C#中有以下脚本将一些XML上传到服务器

using (System.Net.WebClient myWebClient = new System.Net.WebClient())
{
    myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

    //  Post and return Xml
    byte[] bytes = myWebClient.UploadData(url, "POST", System.Text.Encoding.ASCII.GetBytes(Xml_to_Send));
    Xml_Returned = System.Text.Encoding.ASCII.GetString(bytes);
    bytes = null;
}

但是我需要一些对PHP做同样的等价物。

我应该使用什么功能来模拟这样的东西?

1 个答案:

答案 0 :(得分:0)

您可以使用PHP CURL库以这种方式上传文件。查看本指南:

http://blogs.digitss.com/php/curl-php/posting-or-uploading-files-using-curl-with-php/

相关问题