2015-11-02 68 views
0

我使用WWW(不是WWWForm)将图像文件上传到服务器。
当我在iOS 9或更低版本上运行时可以,但是当我在iOS 9.1上测试时,WWW会返回“超时”错误。
任何人都知道这个错误:((iOS 9.1上的Unity WWW超时错误

string server_ip = url; 
byte[] file_byte_array = array_of_file; 
var post_header = new Dictionary<string, string>(); 
WWW stream = new WWW(server_ip, file_byte_array, post_header); 

yield return www; 

if(www.error != null) 
{ 
    Debug.LogError("ERROR : " + www.error); 
} 
+0

欢迎StackOverflow的!请有读[如何提出一个很好的问题] (http://stackoverflow.com/help/how-to-ask)!电话我们已经尝试过了,并提供了所有必要的细节。 –

+0

它是否通过HTTP?你是否禁用了应用程序传输安全检查 – peterept

+0

@peterept是啊,它是通过HTTP,但是当我**下载**一个图像时,没关系。我**上传**图像时返回错误:(( –

回答

0

好吧,我不能使用WWW上传,所以我尝试了C#的Socket

  request.Method = "POST"; 
      request.ContentType = "text/plain"; 

      byte[] fileToSend = arrByteAva; 
      request.ContentLength = fileToSend.Length; 

      using (Stream requestStream = request.GetRequestStream()) 
      { 
       // Send the file as body request. 
       requestStream.Write(fileToSend, 0, fileToSend.Length); 
       requestStream.Close(); 
      } 
0

我想这是因为Xcode中7.您的info.plist添加这个AppTransport安全:NSAppTransportSecurity型词典和这里面添加具有布尔类型NSAllowArbitraryLoads并将其设置为YES