Using AFNetWorking 2.0 upload file to php web service server based on Slim
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的更多相关文章
- ASP.NET4.0中JavaScript脚本调用Web Service 方法
环境:VS2019 .net 4.0 framework 根据教材使用ScriptManager在JavaScript中调用Web service 时,失败.现将过程和解决方法记录如下: 1.定义W ...
- AFNetworking 3.0.4 的使用
本文永久链接:http://www.cnblogs.com/qianLL/p/5342593.html pod 'AFNetworking', '~>3.0.4' <-------第 ...
- AFNetworking 2.0使用(持续更新)
本人视频教程系列 导入AFNetworking 2.0 文件夹,引入头文件AFNetworking.h --------------- *使用NSURLSessionDownloadTask来下载一张 ...
- [翻译] AFNetworking 2.0
大名鼎鼎的开源网络库AFNetworking 2.0,目前只是翻译了Github上的链接文章,使用教程请点击 http://www.cnblogs.com/YouXianMing/p/3651462. ...
- AFNetworking 3.0 源码解读(三)之 AFURLRequestSerialization
这篇就讲到了跟请求相关的类了 关于AFNetworking 3.0 源码解读 的文章篇幅都会很长,因为不仅仅要把代码进行详细的的解释,还会大概讲解和代码相关的知识点. 上半篇: URI编码的知识 关于 ...
- AFNetworking 3.0 源码解读(五)之 AFURLSessionManager
本篇是AFNetworking 3.0 源码解读的第五篇了. AFNetworking 3.0 源码解读(一)之 AFNetworkReachabilityManager AFNetworking 3 ...
- jQuery文件上传插件jQuery Upload File 有上传进度条
jQuery文件上传插件jQuery Upload File 有上传进度条 jQuery文件上传插件jQuery Upload File,插件使用简单,支持单文件和多文件上传,支持文件拖拽上传,有进度 ...
- AFNetworking 3.0 版本使用
原创:http://www.zhimengzhe.com/IOSkaifa/38653.html AFNetworking 3.0 版本使用 在Xcode7.0之后,苹果废弃了NSURLConnect ...
- Upload file
<h3>Upload File</h3> <form action="@Url.Action("Upload","UploadCo ...
随机推荐
- OpenSSL - 文件和字符MD5加密实现
OpenSSL安装: 1.github下载最新的OpenSSL:https://github.com/openssl/openssl 2.在linux解压压缩包 3.安装OpenSSL ./confi ...
- C#中using关键字的作用及用法
using的用途和使用技巧. 1. 引用命名空间 2. 为命名空间或类型创建别名 3. 使用using语句 1. 引用命名空间,这样可以在程序中引用命名空间的类型而不必指定详细的命名空间. a ...
- CCLabel在最大宽度已知的情况下如何获取实际宽高
当前环境在cocos2.2.6, 在UI摆图中,会遇到一种情况就是 设定了label的最大宽度MAX_WIDTH,但label的内容是动态的,如何在label输入了文字之后获取label的真实宽高? ...
- DAO接口及实现类
DAO接口中定义了所有的用户操作,如添加记录.删除记录及查询记录. package chapter13; import java.util.*; public interface UserDAO { ...
- 诺基亚XL中Intent.ACTION_VIEW无效的问题
今天测试播放视频的时候,发现在诺基亚XL机型里不能弹出视频应用列表. 我的代码是: Intent intent = new Intent(Intent.ACTION_VIEW); intent.set ...
- 原生javascript里jsonp的实现原理
ajax不能跨域,jsonp可以跨域 跨域的核心思想: 调用(拿到的接口),定义(jsonp核心处理器)分别是不同的script标签里面进行跨script取数据(只有get方式进行取数据 ) ...
- ajax+php处理案例
<div> <table> <tr> <th>状态</th> <th>信息</th> </tr> < ...
- Python字典实现三级菜单
################################################ # Task Name: 三级菜单 # # Description:打印省.市.县三级菜单 # # 可 ...
- python笔记集合
1.win_64下编译pyd(编译器用的tdm-gcc-5.1) gcc test.c -shared -Ic:\Python27\include -Lc:\Python27\libs -lpytho ...
- sqlserver 跨服务器访问数据
需求:两个一模一样的表,分别分布在两个服务器的数据库上,现在要在一个表中,查看这两个表的内容,并让Id排序 1:在本地数据库查询分析器中,运行以下两段语句: --创建链接服务器 exec sp_add ...