Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:05:25+00:00 2026-05-25T22:05:25+00:00

Somebody please… #$%^ please take a look at this. days walking through the debugger,

  • 0

Somebody please… #$%^ please take a look at this. days walking through the debugger, using setData with a jpeg representation. set file using ios4 asset library, trying a new PHP script, deleting the asiHTTPrequest files and making damn sure I have the new ones. Still nothing… Half the code has been put together from examples here or elsewhere on the web.

The goal here, is to simply pick a photo from the camera roll, and upload it, seems pretty easy, I had a different PHP script that was working fine from the desktop and nabbed one from here because it’s much more concise and it works from the desktop as well.

so the override for finishing image picking

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
UIImage *originalImage, *editedImage, *imageToSave;

// dealing with a still image
if(CFStringCompare((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo){

    editedImage = (UIImage *) [info objectForKey:UIImagePickerControllerEditedImage];

    originalImage = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];

    /*
    if(editedImage){
        imageToSave = editedImage;
    } else {
        imageToSave = originalImage;
    }
    */
    chosenImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];

    [[picker parentViewController] dismissModalViewControllerAnimated:YES];

    //_imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation(originalImage, 0.0)];
    //_imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation(chosenImage.image, 0.0)];

    UIImage *im = [info objectForKey:@"UIImagePickerControllerOriginalImage"] ;
    UIGraphicsBeginImageContext(CGSizeMake(320,480)); 
    [im drawInRect:CGRectMake(0, 0,320,480)];
    _resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext();
    _imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation(_resizedImage, 0.0)];

    }
    [picker release];
}

then the upload method.

-(void)uploadPhoto
{
//NSLog(@"image path inside uploadPhoto --> %@", _imagePath);
NSLog(@"uploadPhoto");


//NSLog(@"%@", imageData);

//_imageData = _imageData;

NSString *unescapedURL = @"http://dev.xxxx.com/upload.php";

NSString * escapedURL =
(NSString *)CFURLCreateStringByAddingPercentEscapes(
                                                    NULL,
                                                    (CFStringRef)unescapedURL,
                                                    NULL,
                                                    (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                    kCFStringEncodingUTF8 );


NSURL *url = [NSURL URLWithString:unescapedURL];
//NSURL *url = [NSURL URLWithString:unescapedURL];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setRequestMethod:@"POST"];
//[request setStringEncoding:NSUTF8StringEncoding];
//[request addPostValue:@"submit" forKey:@"Submit"];
//[request setPostValue:@"Submit" forKey:@"Submit"];
[request setData:_imageData withFileName:@"image4.jpg" andContentType:@"image/jpeg" forKey:@"photo"];
//[request setFile:_imagePath forKey:@"photo"];
//[request setFile:_imagePath withFileName:@"image5.png" andContentType:@"image/png" forKey:@"photo"];
[request setDidFailSelector:@selector(requestFailed:)];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setTimeOutSeconds:500];
[request startAsynchronous];

NSError *error = nil;
NSString *theString = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
if( theString )
{
    NSLog(@"Text=%@", theString);
}
else 
{
    NSLog(@"Error = %@", error);
    NSString *localized = [error localizedDescription];
    NSString *localizedFail = [error localizedFailureReason] ? [error localizedFailureReason] : NSLocalizedString(@"not it", nil);
    NSLog(@"localized error--> %@", localized);
    NSLog(@"localizedFail--> %@", localizedFail);

}

[escapedURL release];

}

then the finish/fail selectors

-(void)requestFinished:(ASIFormDataRequest *)request
{
    NSLog(@"requestFinished");
    NSString *respondingString = [request responseString];
    NSLog(@"response string--> %@", respondingString);

    NSData *responseData = [request responseData];
    NSLog(@"%@", responseData);
}

-(void)requestFailed:(ASIFormDataRequest *)request
{
    NSLog(@"requestFailed");
    //NSError *error = [request error];
    //NSLog(@"%@", [error description]);
}

Help! Drowning…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:05:25+00:00Added an answer on May 25, 2026 at 10:05 pm

    It was a problem with the PHP.

    move_uploaded_file($_FILES["file"]["tmp_name"]
    

    was the issue.

    if you look at this

    [request setData:_imageData withFileName:@"image4.jpg" andContentType:@"image/jpeg" forKey:@"photo"];
    

    It’s changing the POST so the standard…

    move_uploaded_file($_FILES["file"]["tmp_name"]
    

    needs to be

    move_uploaded_file($_FILES["photo"]["tmp_name"]
    

    adding

    error_reporting(E_ALL);
    ini_set("display_errors", 1); 
    print_r($_FILES);
    

    to the PHP allowed me to see..

    response string--> Array
    (
        [photo] => Array
            (
                [name] => image4.jpg
                [type] => image/jpeg
                [tmp_name] => /tmp/phpCSXJgl
                [error] => 0
                [size] => 150854
            )
    
     )
    

    in the selector defined by…

    [request setDidFinishSelector:@selector(requestFinished:)];
    

    What I’ll do from here is revert the PHP to where it was before

    move_uploaded_file($_FILES["file"]["tmp_name"]
    

    and change the setFile call to

    [request setData:_imageData withFileName:@"image4.jpg" andContentType:@"image/jpeg" forKey:@"file"];
    

    all will be well with the world and I’m going to get some food. cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could somebody please provide a step-through approach to solving the following problem using the
Somebody please help me out. This problem is killing me. I went through tones
Could somebody please name a few. I could given time, but this is for
Can somebody please explain what does this warning mean: undefined reference to 'WinMain@16' ?
Can somebody please explain this IE7 bug to me? It occurs in Standards and
Could somebody please take some time to show me a quick example on how
can somebody please explain is it possible to convert this snippet of the code
Could somebody please explain to me why does this code only print 42 instead
Could somebody please explain this piece of Ruby code: def add_spec_path_to(args) # :nodoc: args
Can somebody please give me some links / tutorials to using SQLite file thatis

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.