我正在尝试使用 php 将 uiimage 从我的手机应用程序上传到服务器。但有些它不起作用。有人可以帮我吗?我的代码:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]];
request.delegate = self;
request.tag = 33;
[request setPostValue:[NSString stringWithFormat:@"%@.png",responseString] forKey:@"name"];
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/MyImage.png", docDirectory];
[request setFile:filePath forKey:@"photo"];
[request startAsynchronous];
[url release];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"aResponse:%@",response);
}
if(move_uploaded_file($_FILES['photo']['tmp_name'],$target_path)) {
echo "The file ". basename( $_FILES['photo']['tmp_name'])." has been uploaded";
}
else {
echo "There was an error uploading the file, please try again!";
}
>
在 ASI 请求文件中使用 nszombie 进行调试时出现以下错误
* -[CFString release]:消息发送到已释放的实例 0xd1dfd80
最佳答案
不要释放 URL:请求将异步运行,因此在您释放它时它还没有完成。
关于iphone - 上传图片 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9719435/