【问题标题】:iPhone how to compress the files while upload to server?iPhone如何在上传到服务器时压缩文件?
【发布时间】:2012-01-09 09:08:08
【问题描述】:

从 iPhone 压缩和上传文件的最佳方式是什么?我正在使用 ASIHTTP 将文件上传到我的服务器。但是在将大文件上传到服务器时出现网络错误。那么如何使用 ASIHTTP 压缩和上传呢?

Code:
[serverUploadRequest setPostValue:withEmail_id forKey:@"mail_id"];
    [serverUploadRequest setPostValue:withPassword forKey:@"pwd"];
    [serverUploadRequest setPostValue:withFileName forKey:@"file_name"];
    [serverUploadRequest setPostValue:withFileExtension forKey:@"file_extension"];
[serverUploadRequest setData:fileData withFileName:withFileName andContentType:@"application/octet-stream" forKey:@"userfile"];

[serverUploadRequest startSynchronous];

这工作正常,但是当我尝试上传大文件时,有时会出现上传失败错误。因此可以将文件压缩并上传到服务器。我正在使用带有 PHP 的 windows 2003 服务器

谢谢

【问题讨论】:

  • 邮政编码和错误以获得更好的结果
  • 我要上传文本文件或pdf文件。
  • 您能否发布您的网络服务器日志,以便我们了解您遇到了什么样的错误(正文太长...)

标签: iphone ios


【解决方案1】:

使用Objective-Zip 压缩文件。

有关其用法的更多信息,请访问link

【讨论】:

  • 所有链接都已损坏。请修复或删除?谢谢!
【解决方案2】:

May this link useful to you 您可以在上传到服务器之前压缩文件。

【讨论】:

    【解决方案3】:

    【讨论】:

      【解决方案4】:

      这是我用来创建 zip 以上传 3 张图片的简单方法。

      -(void)zipImage:(NSString *) filename: (NSString *) file1: (NSString *) file2: (NSString *) file3{
      
      ZipArchive *zipfile = [[ZipArchive alloc]init];
      [zipfile CreateZipFile2:filename];
      [zipfile addFileToZip:file1 newname:@"C1.jpg"];
      [zipfile addFileToZip:file2 newname:@"C2.jpg"];
      [zipfile addFileToZip:file3 newname:@"T1.jpg"];
      [zipfile CloseZipFile2];
      
      }
      

      zip 库是 miniZip (http://code.google.com/p/ziparchive/)

      如您所见,最初的调用是初始化 ZipArchive 对象,接下来创建 zipfile,然后为文件中所需的每个项目递归调用 addFileToZip。

      P.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多