将iOS上传到PHP

时间:2013-04-18 04:58:21

标签: php ios

我目前正在尝试将图像从iOS应用程序上传到php后端。我在网上跟踪了样本;但是,我收到的PHP错误代码为3(UPLOAD_ERR_PARTIAL)。谁能帮我吗?我正在使用[NSURLConnection sendAsynchronousRequest:queue:completionHandler]。

我已经阅读了一些人禁用Connection标头,但这也无效。我应该检查一下服务器端吗?

<?
$uploaddir = '';      //Uploading to same directory as PHP file
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;

if ($_FILES['userfile']['error'] === UPLOAD_ERR_OK) {

} else {
    die("Upload failed with error code " . $_FILES['userfile']['error']);
}
?>

1 个答案:

答案 0 :(得分:0)

你可以使用iOS的POST / GET方法在php上传/发送任何数据。

for post method

HTTP Post method php and ios

Get方法

http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/

对于两者

How to send POST and GET request?