我正在通过 MKnetwork 将图像发送到 php 服务器......在 php 端,图像是在 $_POST 而不是 $_FILES 中接收的......这是我来自 ios 端的代码
UIImage *image = [UIImage imageWithContentsOfFile:fullImgPath];// fullpath contains the path of image
NSData *imageData = UIImageJPEGRepresentation(image, 0.0);
MKNetworkEngine *engine=[[MKNetworkEngine alloc]initWithHostName:nil];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setValue:imageData forKey:@"uploadedfile"];
NSString *url=@"http://ilogiks.co.uk/demo/image/upload.php";
MKNetworkOperation *op=[engine operationWithURLString:url params:dict httpMethod:@"POST"];
从php方面
echo "POST";
var_dump($_POST);
echo "FILES";
var_dump($_FILES);
$_FILES 显示空图像和 $_POST 显示以下响应
array(1){
["uploadedfile"]=>
string(50523) "<ffd8ffe0 00104a46 49460001.............
我希望在 $_FILES 中接收图像,以便我可以保存它,或者是否有其他解决方案?请帮忙