使用Asihttprequest将文件上传到服务器,我有2个问题:
她是我的代码:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http:xxxxx" ]];
[request setDownloadProgressDelegate:progresse];
[request setPostValue:@"upload" forKey:@"action"];
[request addData:[NSData dataWithData:UIImageJPEGRepresentation([UIImage imageNamed:@"xxxxx.jpg"],0.9)] withFileName:@"img.jpg" andContentType:@"image/jpeg" forKey:@"img"];
[request startAsynchronous];
服务器端:
if(isset($_FILES['img']))
{
$dossier = 'upload/';
$fichier = basename($_FILES['img']['name']);
if(move_uploaded_file($_FILES['img']['tmp_name'], $dossier . $fichier))
{
echo 'ok!';
}
else
{
echo 'fail !';
}
}
想你。
答案 0 :(得分:0)