Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload image file in server using ASIHTTPRequest from IPhone app
    primarykey
    data
    text
    <p>I want to upload images in server using ASIHTTPRequest library in my IPhone app.</p> <p>For image upload, i am using ASIFormDataRequest to upload into server.</p> <p>I have tried the below codes in my app but it couldn't working and image didn't uploaded in server.</p> <pre><code>NSURL *url = [NSURL URLWithString:@"http://www.anglerdemo.com/Appln/Aghaven_iphone/Uploadphoto.php"]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; request.requestMethod = @"POST"; NSString *fileName = @"iphone.jpg"; [request addPostValue:fileName forKey:@"name"]; // Upload an image UIImage *img = [UIImage imageNamed:fileName]; NSData *imageData = UIImageJPEGRepresentation(img, 90); NSLog(@"imageData ==&gt; %@", imageData); [request setData:imageData withFileName:fileName andContentType:@"image/jpeg" forKey:@"image"]; [request setDelegate:self]; [request startAsynchronous]; </code></pre> <p>I have tried above codes in my app, request successfully executed and i got the alert message in "requestFinished" delegate method of ASIHTTPRequest. but image didn't uploaded in server.</p> <pre><code>- (void)requestFinished:(ASIHTTPRequest *)request { [[[[UIAlertView alloc] initWithTitle:@"Message" message:@"Success!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show]; NSLog(@"success ==&gt; "); } </code></pre> <p>I have tried php file script for upload is below.</p> <pre><code>&lt;?php $uploaddir = 'upload_files/'; $file = basename($_FILES['image']['name']); $uploadfile = $uploaddir . $file; if(move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { echo "Photo has been saved successfully!…; } else { echo "Failed"; } ?&gt; </code></pre> <p>Please help in this regards.</p> <p>Thanks!!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload