地址确定正确没有笔误?我看你HTML里的地址是带空格的。。
建议你用HTTP sniffer之类的截一下Http请求包,看看是不是一致。
从代码上看貌似没有什么问题。另外域名还是IP,是有区别的,如果html表单是在域名下提交的,
CURL的地址也应该用域名才行,反之也一样。

解决方案 »

  1.   

    地址没有错,HTML带空格是我笔误。都是用域名访问的,下面是我用HttpNetworkSniffer抓包的记录,您帮我看一下哪里出了问题啊。VC代码提交的:
    ==================================================
    主机名               : ***f.****p.com
    请求方式              : POST
    路径                : /p****/toocle_faxsend.jsp
    用户代理              : 
    响应码               : 100
    响应文本              : Continue
    内容类型              : 
    来源页面              : 
    内容编码              : 
    传输编码              : 
    服务器信息             : 
    内容长度              : 0
    连接                : 
    缓存控制              : 
    Location          : 
    Server Time       : 
    Expiration Time   : 
    Last Modified Time: 
    Cookie            : 
    客户端地址             : 192.168.0.125:3743
    服务器地址             : ***.191.***.**0:80
    请求时间              : 00:00:00.000
    Response Time     : 250 ms
    URL               : http://***f.***p.com/p****/toocle_faxsend.jsp
    ==================================================HTML提交的:
    ==================================================
    主机名               : ***f.****p.com
    请求方式              : POST
    路径                : /p****/toocle_faxsend.jsp
    用户代理              : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; .NET CLR 1.1.4322)
    响应码               : 200
    响应文本              : OK
    内容类型              : text/html;charset=gb2312
    来源页面              : http://192.168.0.125:8080/
    内容编码              : 
    传输编码              : 
    服务器信息             : Apache-Coyote/1.1
    内容长度              : 124
    连接                : 
    缓存控制              : no-cache
    Location          : 
    Server Time       : 2013/11/18 5:24:35
    Expiration Time   : 
    Last Modified Time: 
    Cookie            : 
    客户端地址             : 192.168.0.125:3754
    服务器地址             : ***.191.***.**0:80
    请求时间              : 00:01:27.954
    Response Time     : 186 ms
    URL               : http://***f.***p.com/p****/toocle_faxsend.jsp
    ==================================================
      

  2.   

    ...
    用wireshark或则Microsoft Network Monitor 3.4抓一下包。
    你打印的信息连基本的包结构都没怎么好对比分析呢。
    这样对比就容易知道参数哪里不对了,还是Cookie什么的没有设置好。
      

  3.   


    我截获的包,请您帮我看看。请把图片另存为到本地,并改后缀为rar,里面有两个Wireshark抓的包,谢谢啊!我刚还是接触http编程,实在是不懂。。
      

  4.   


    私信邮件地址
    我刚才试了一下,使用迅雷下载我上面那个帖子的图片,下载下来以后重命名后缀为rar即可解压。
      

  5.   

    看见图了吗?
    HTML版本只提交了一个表单,App版本提交了3个表单。。
    CURL的Post追加参数用法不当
    试试用curl_easy_setopt(, CURLOPT_COPYPOSTFIELDS);一口气设上
      

  6.   


    在网上找了一圈没找到这个CURLOPT_COPYPOSTFIELDS参数怎么用根据我这情况该怎么设置这个参数啊?需要传的参数为两个“text”类型,一个“file”类型太感谢了!
      

  7.   

    我直接在浏览器地址栏提交有问题
    http://****.***p.com/p*****/toocle_faxsend.jsp?FILE=D:\testFax.doc&timestamp=20131119091701&receiverfaxlist=0531123456
      

  8.   


    不用curl_formadd试试curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "FILE=D:\\testFax.doc&timestamp=20131119091701&receiverfaxlist=0531123456");
      

  9.   


    不用curl_formadd试试curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "FILE=D:\\testFax.doc&timestamp=20131119091701&receiverfaxlist=0531123456");不行啊,我把代码改成这样:CTime time = CTime::GetCurrentTime();    
    CString tt = time.Format("%Y%m%d%H%M%S");     std::string strResponse;    
    curl_global_init(CURL_GLOBAL_ALL);   
    CURL* hCurl = curl_easy_init();     
    if(hCurl != NULL)     
    {         
    curl_easy_setopt(hCurl, CURLOPT_URL, ISPurl.GetBuffer(0));  
    //  struct curl_httppost *post=NULL;        
    //  struct curl_httppost *last=NULL;        
    //  curl_formadd(&post, &last,  CURLFORM_COPYNAME, "timestamp",   CURLFORM_COPYCONTENTS, tt.GetBuffer(0), CURLFORM_END);         
    //  curl_formadd(&post, &last,   CURLFORM_COPYNAME, "receiverfaxlist",   CURLFORM_COPYCONTENTS, TelNum.GetBuffer(0), CURLFORM_END);        
    //  curl_formadd(&post, &last,   CURLFORM_COPYNAME, "FILE",   CURLFORM_FILECONTENT,FilePath.GetBuffer(0),CURLFORM_END);           
    curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS, "FILE=D:\\testFax.doc&timestamp=20131119131701&receiverfaxlist=0531123456");
    curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, NULL);        
    curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, OnWriteData);       
    curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *)&strResponse);         
    curl_easy_setopt(hCurl, CURLOPT_NOSIGNAL, 1);      
    curl_easy_setopt(hCurl, CURLOPT_CONNECTTIMEOUT, 3);      
    curl_easy_setopt(hCurl, CURLOPT_TIMEOUT, 3);        
    curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION,1); //是否抓取跳转后的页面       
    /* Set the form info */          
    // curl_easy_setopt(hCurl, CURLOPT_HTTPPOST, post);      
    curl_easy_perform(hCurl); /* post away! */       
    /* free the post data again */        
    //curl_formfree(post);       
    curl_easy_cleanup(hCurl);   
    }       
    curl_global_cleanup(); 
    CString FaxID, FaxTime; 
    int code;      
    code = CheckFaxReturnValue(strResponse.c_str(),FaxID, FaxTime); 
    CString tempp;   
    tempp.Format("状态:%s, ID:%s, time:%s", GetErrorDesc(code), FaxID, FaxTime); 
    AfxMessageBox(tempp);抓的包如下:app还是那个错误提示。究竟哪有问题啊
      

  10.   

    我晕,我翻了一下资料,你是要上传文件吧?
    我一直以为直接Post表单然后拿数据。。那你试试这样的:curl_formadd(&post, &last,  
    CURLFORM_COPYNAME, "FILE",   CURLFORM_FILE,"D:\\testFax.doc",
    CURLFORM_FILENAME, "testFax.doc", CURLFORM_CONTENTTYPE, "application/msword",
    CURLFORM_END);  
      

  11.   

    基本上应该是一个表单把所有的参数传上去。。
    如果要附带额外参数参考示例代码:
    multi-post.c
      

  12.   

    解决了,最后代码改成这样就可以上传了std::string strResponse;    
    curl_global_init(CURL_GLOBAL_ALL);   
    CURL* hCurl = curl_easy_init();     
    if(hCurl != NULL)     
    {         
    curl_easy_setopt(hCurl, CURLOPT_URL, ISPurl.GetBuffer(0));  
    struct curl_httppost *post=NULL;        
    struct curl_httppost *last=NULL;        
    //   curl_formadd(&post, &last,  CURLFORM_COPYNAME, "timestamp",   CURLFORM_COPYCONTENTS, tt.GetBuffer(0),
    //  CURLFORM_COPYNAME, "receiverfaxlist",  CURLFORM_COPYCONTENTS, TelNum.GetBuffer(0),
    //  CURLFORM_COPYNAME, "FILE", CURLFORM_FILE,FilePath.GetBuffer(0),CURLFORM_END);   
    curl_formadd(&post, &last,   CURLFORM_COPYNAME, "FILE",   CURLFORM_FILE,FilePath.GetBuffer(0),CURLFORM_END);    
       curl_formadd(&post, &last,  CURLFORM_COPYNAME, "timestamp",   CURLFORM_COPYCONTENTS, tt.GetBuffer(0),CURLFORM_END);  
    curl_formadd(&post, &last,   CURLFORM_COPYNAME, "receiverfaxlist",   CURLFORM_COPYCONTENTS, TelNum.GetBuffer(0), CURLFORM_END);        
           
    // curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS, "FILE=D:\\testFax.doc&timestamp=20131119131701&receiverfaxlist=0531123456");
    curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, NULL);        
    curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, OnWriteData);       
    curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *)&strResponse);         
    curl_easy_setopt(hCurl, CURLOPT_NOSIGNAL, 1);      
    curl_easy_setopt(hCurl, CURLOPT_CONNECTTIMEOUT, 3);      
    curl_easy_setopt(hCurl, CURLOPT_TIMEOUT, 3);        
    curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION,1); //是否抓取跳转后的页面       
    /* Set the form info */          
    curl_easy_setopt(hCurl, CURLOPT_HTTPPOST, post);      
    curl_easy_perform(hCurl); /* post away! */       
    /* free the post data again */        
    curl_formfree(post);       
    curl_easy_cleanup(hCurl);   
    }       
    curl_global_cleanup(); 但是最后捕获的包还是有不一样的地方,这个CSDN不知道为啥上传jpg总是失败,传不上来包的截图。
    我把截图发您邮箱里,您有时间帮我看看吧!太感谢您了!
      

  13.   

    图片看到了,
    1.默认的CURL的Context-Type就是 "application/octet-stream"
    使用CURLFORM_CONTENTTYPE标记可以改变Context-Type2.你在程序里提交三个参数就是三个参数。HTML可能附加了其他的东西。