Request-URI Too Large 错误出现[使用 base64 编码图像并发送到 php 时]

Posted

技术标签:

【中文标题】Request-URI Too Large 错误出现[使用 base64 编码图像并发送到 php 时]【英文标题】:Request-URI Too Large error came [while encoding image using base64 and send to php] 【发布时间】:2014-02-11 12:40:32 【问题描述】:

    编码:

     NSData *imageData2 =UIImageJPEGRepresentation(image_emp.image, 0.1);
    [Base64 initialize];
     NSString *encodedString = [imageData2 base64EncodedStringWithOptions:0];
    

      json:

      NSString *posturl=[NSString stringWithFormat:@"http://xxxx.com/image.php?img=%@",encodedString];
      //[posturl stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
      
      
        NSString* urlTextEscaped = [posturl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
       NSLog(@"replace log %@",urlTextEscaped);
      
       [urlTextEscaped stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
      
       NSLog(@"the office login url is %@",posturl);
       NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@",urlTextEscaped]];
      
       //  NSURL *url=[NSURL URLWithString:[posturl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
      
       NSMutableURLRequest *request=[[NSMutableURLRequest alloc]init];
       [request setURL:url];
      
      
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        NSError *error;
        NSURLResponse *response;
      
        NSData *urldata=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
        NSString *data=[[NSString alloc]initWithData:urldata encoding:NSUTF8StringEncoding];
        NSLog(@"the overall value is %@",data);
      
      
         NSDictionary *results=[data JSONValue];
          NSLog(@"the results:%@",results);
         NSArray *value=[results objectForKey:@"message"];
           NSLog(@"the array value %@",value);
      

      数组值[log]:

           Request-URI Too Large
      

我该如何解决此类问题。请提供任何想法。在此先感谢。

【问题讨论】:

与您的问题无关,给您的一般建议:您永远不应该手动拨打+ initialize。第一次使用该类时会自动调用它。 【参考方案1】:

不要在 URL 中发布数据,利用帖子正文并在那里提交。这是获取大量提交数据的唯一方法。

【讨论】:

以上是关于Request-URI Too Large 错误出现[使用 base64 编码图像并发送到 php 时]的主要内容,如果未能解决你的问题,请参考以下文章

nginx出现 “414 request-uri too large”

nginx出现 “414 request-uri too large”

nginx 414 Request-URI Too Large

WCF错误:413 Request Entity Too Large

nginx-413-Request Entity Too Large

nginx-413-Request Entity Too Large