Recently i am developing the IOS app, a feature is needed to upload image to the webservice server. I am using the AFNetworking library. The function is as follow.

-(void)SendImage:(NSData *)imgData {

NSDictionary *parameters = @{@"ShopID": [NSString stringWithFormat:@"%d", 1],

@"ImageID": @"0"

};

NSString *szAddress = utilityGetRequestAddress( EASYQ_CMD_UPLOAD_IMAGE );

httpRequestManager.responseSerializer = [AFJSONResponseSerializer serializer];

[httpRequestManager POST:szAddress parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

[formData appendPartWithFormData:imgData name:@"ShopImage"];

} success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSLog(@"Success: %@", responseObject);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"Error: %@", error);

}];

}

There is one thing need to be noticed. In the server side, i am using Slim framework, when i try to using variable $_FILES["ShopImage"] to get the image, it returns null. Finally i found i need to use $app->request->post('ShopImage') to get the image data.

Using AFNetWorking 2.0 upload file to php web service server based on Slim的更多相关文章

  1. ASP.NET4.0中JavaScript脚本调用Web Service 方法

    环境:VS2019  .net 4.0 framework 根据教材使用ScriptManager在JavaScript中调用Web service 时,失败.现将过程和解决方法记录如下: 1.定义W ...

  2. AFNetworking 3.0.4 的使用

    本文永久链接:http://www.cnblogs.com/qianLL/p/5342593.html pod 'AFNetworking', '~>3.0.4'    <-------第 ...

  3. AFNetworking 2.0使用(持续更新)

    本人视频教程系列 导入AFNetworking 2.0 文件夹,引入头文件AFNetworking.h --------------- *使用NSURLSessionDownloadTask来下载一张 ...

  4. [翻译] AFNetworking 2.0

    大名鼎鼎的开源网络库AFNetworking 2.0,目前只是翻译了Github上的链接文章,使用教程请点击 http://www.cnblogs.com/YouXianMing/p/3651462. ...

  5. AFNetworking 3.0 源码解读(三)之 AFURLRequestSerialization

    这篇就讲到了跟请求相关的类了 关于AFNetworking 3.0 源码解读 的文章篇幅都会很长,因为不仅仅要把代码进行详细的的解释,还会大概讲解和代码相关的知识点. 上半篇: URI编码的知识 关于 ...

  6. AFNetworking 3.0 源码解读(五)之 AFURLSessionManager

    本篇是AFNetworking 3.0 源码解读的第五篇了. AFNetworking 3.0 源码解读(一)之 AFNetworkReachabilityManager AFNetworking 3 ...

  7. jQuery文件上传插件jQuery Upload File 有上传进度条

    jQuery文件上传插件jQuery Upload File 有上传进度条 jQuery文件上传插件jQuery Upload File,插件使用简单,支持单文件和多文件上传,支持文件拖拽上传,有进度 ...

  8. AFNetworking 3.0 版本使用

    原创:http://www.zhimengzhe.com/IOSkaifa/38653.html AFNetworking 3.0 版本使用 在Xcode7.0之后,苹果废弃了NSURLConnect ...

  9. Upload file

    <h3>Upload File</h3> <form action="@Url.Action("Upload","UploadCo ...

随机推荐

  1. C#与XML Schema的问题

    http://bbs.csdn.net/topics/50493564 weileily: 用XmlSchema.Read方法读取了一个xsd文件,请问如何遍历检索器中的ComplexType与Sim ...

  2. 看啦这么就别人的博客 我也来写一篇! Object转换其他类型

    package com.sinitek.framework.util; import java.math.BigDecimal;import java.sql.Timestamp;import jav ...

  3. super.onCreate(SavedInstanceState);

    super.onCreate(SavedInatanceState)时调用父类的构造方法,SavedInstanceState是保存当前Activity的状态信息. onCreate方法的参数是Bun ...

  4. windows 下mysql每日定时备份的几种方法

    第一种:新建批处理文件 backup.dat,里面输入以下代码:  代码如下 复制代码 net stop mysql xcopy "C:/Program Files/MySQL/MySQL ...

  5. 【转载】AngularJs 指令directive之controller,link,compile

    关于自定义指令的命名,你可以随便怎么起名字都行,官方是推荐用[命名空间-指令名称]这样的方式,像ng-controller.不过你可千万不要用 ng-前缀了,防止与系统自带的指令重名.另外一个需知道的 ...

  6. hdu4737 A Bit Fun

    link:http://acm.hdu.edu.cn/showproblem.php?pid=4737 暴力可以过啊.O(N^2)的复杂度. #include <cstdio> ]; in ...

  7. HttpSendRequest同步请求不返回

    HttpSendRequest是基于socket实现的 在工作过程中发现当发送请求时 1.当网络没有连接时 会同步返回失败 2.当发送请求时 把网线拔下也是会同步返回失败 3.但是第三种情况 发送请求 ...

  8. Faster-RCNN 训练自己的数据

    在前一篇随笔中,数据制作成了VOC2007格式,可以用于Faster-RCNN的训练. 1.针对数据的修改 修改datasets\VOCdevkit2007\VOCcode\VOCinit.m,我只做 ...

  9. 关于URL编码

    关于URL编码 作者: 阮一峰 日期: 2010年2月11日 一.问题的由来 URL就是网址,只要上网,就一定会用到. 一般来说,URL只能使用英文字母.阿拉伯数字和某些标点符号,不能使用其他文字和符 ...

  10. MVC 记录操作日志与过滤特殊字符

    最近进行的MVC系统需要用到记录操作日志和过滤特殊字符的功能,如果每个action中都调用记录日志的方法就太麻烦了,所以根据需要结合mvc的过滤机制 写了个特殊字符验证与记录操作日志的公用类: pub ...