开发者

iPhone webservices ASIHTTPRequest

开发者 https://www.devze.com 2023-04-04 14:15 出处:网络
I have an image taken with the photopicker i try to upload with the ASIHTTPRequest like this: NSData *imageData = UIImageJPEGRepresentation(image, 80);

I have an image taken with the photopicker i try to upload with the ASIHTTPRequest like this:

NSData *imageData = UIImageJPEGRepresentation(image, 80);
[request setData:imageData withFileName:@"test.jpg" andContentType:@"image/jpg" forKey:@"file"];

The issue is, on the php end of things, with this snippet:

$target_path = "files/";

target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  echo "Image: ".  basename( $_FILES['uploadedfile']['name']). 
" has been uploaded";
 } else{
   echo "error uploading";
 }

However, it keeps returning that the upload has failed, no matter what I u开发者_如何学Gopload.


You are uploading the file with the key of "file". In your php script you are trying to retrieve a file at the name / key of "uploadedfile" change "uploadedfile" to "file" and it should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号