未收到卷曲PUT数据

我试图解析通过http CURL PUT方法发送的文件。 我使用通用处理程序来解析文件。 我创建了一个通用处理程序来获取发布文件。 以下是ASP.Net代码:

我无法收到任何文件或内容。 我的代码中有任何问题吗? 以下是用于发送文件的CURL脚本:

请帮助我,因为这对我来说非常紧迫。 非常感谢你提前。

public class Test : IHttpHandler {

public void ProcessRequest(HttpContext context)
{
    string result = string.Empty;
    try
    {
        context.Response.ContentType = "text/plain";
        //VALIDATE FILES IN REQUEST
        if (context.Request.Files.Count > 0)
        {
            try
            {
                //HANDLE EACH FILE IN THE REQUEST
                foreach (HttpPostedFile item in context.Request.Files)
                {
                    item.SaveAs(context.Server.MapPath("~/Temp/" + item.FileName));
                    context.Response.Write("FILE UPLOADED");
                }
            }
            catch (Exception ex)
            {
                //NO FILES IN REQUEST TO HANDLE
                context.Response.Write("ERROR: " + ex.Message);
            }
        }
        else
        {
            //NO FILES IN REQUEST TO HANDLE
            context.Response.Write("NO FILE(S) SENT");
        }

       context.Response.Write(result);
    }
    catch (Exception ex)
    {

        //result = "205";
        context.Response.Write(ex.Message);
    }
}

public bool IsReusable
{
    get
    {
        return false;
    }
}


function putRequest($url, $data)
{
    $putData = tmpfile();
    fwrite($putData, $data);
    fseek($putData, 0);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_INFILE, $putData);
    curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
    curl_setopt($ch, CURLOPT_PUT, true);
    curl_exec($ch);
    $headers = curl_getinfo($ch);
    fclose($putData);
    curl_close($ch);
    return $headers['http_code'];
}

$url= " http://api.domain.com/upload/ ";
$data = "21.2,1000,1,2,3,4,5,6,7,8,9";
echo "Starting the put request
"; $ret = putRequest($url,$data); echo "Returned code: $ret
";
链接地址: http://www.djcxy.com/p/48603.html

上一篇: Curl PUT data is not received

下一篇: CURL CouchDB Replication command