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.

时间: 2024-10-09 07:02:47

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.定义Web Service using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace AjaxTest1 { /// <

AFNetworking 3.0.4 的使用

AFNetworking 本文永久链接:http://www.cnblogs.com/qianLL/p/5342593.html pod 'AFNetworking', '~>3.0.4'    <-------第三方 具体他的pod的过过程 http://www.cnblogs.com/qianLL/p/5331624.html 代码如下 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

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

jQuery文件上传插件jQuery Upload File 有上传进度条 2015年05月15日 jQuery文件上传插件jQuery Upload File,插件使用简单,支持单文件和多文件上传,支持文件拖拽上传,有进度条显示.标准HTML form文件上传,也就是说,只要服务端支持接收multipart/form-data格式数据就能使用此上传插件. 本站web端文件文件提交即使用此插件,效果如下: 浏览器支持 浏览器支持:IE 8.0,IE 9.0,IE 10.0,Firefox,Saf

Upload file

<h3>Upload File</h3> <form action="@Url.Action("Upload","UploadController")" method="post" id="uploadForm" enctype="multipart/form-data"> <div class="file-box">

MVC-前台调用后台action 传递upload file 参数问题

在后台获取upload file 数量的时候发现count一直为0,经检查发现了问题 ,代码如下: 前台: var data = $("#DetailForm").serialize(); $.ajax({ url: '@Url.Action("SaveRequest", "RegistrationRequest")', type: "POST", dataType: "JSON", data: data,

最新 AFNetworking 3.0 简单实用封装

AFNetworking 3.0 的到来使我们开发者又方便了许多,话不多说,直接上代码. 1.首先 引入框架AFNetworking框架 GitHub下载地址:https://github.com/AFNetworking/AFNetworking AFNetworking官网地址:http://afnetworking.com 2.导入AFNetworking 支持框架 #import<MobileCoreServices/MobileCoreServices.h> #import<S

Express web框架 upload file

哈哈,敢开源,还是要有两把刷子的啊 今天,看看node.js 的web框架 Express的实际应用 //demo1 upload file <html><head><title>文件上传表单</title></head><body><h3>文件上传:</h3>选择一个文件上传: <br /><form action="/file_upload" method="

AFNetworking 2.0 Tutorial

Update 1/18/2014: Fully updated for iOS 7 and AFNetworking 2.0 (original post by Scott Sherwood, update by Joshua Greene). In iOS 7, Apple introduced NSURLSession as the new, preferred method of networking (as opposed to the older NSURLConnection API

AFNetworking 3.0迁移指南

AFNetworking是一款在OS X和iOS下都令人喜爱的网络库.为了迎合iOS新版本的升级, AFNetworking在3.0版本中删除了基于 NSURLConnection API的所有支持.如果你的项目以前使用过这些API,建议您立即升级到基于 NSURLSession 的API的AFNetworking的版本.本指南将引导您完成这个过程. 本指南是为了引导使用AFNetworking 2.x升级到最新的版本API,以达到过渡的目的,并且解释了新增和更改的设计结构. 新设备要求: iO