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

  • Home
  • SEARCH
  • 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 4038504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:28:51+00:00 2026-05-20T12:28:51+00:00

I do have some image files(.png files) in document directory(iPhone). I am viewing web

  • 0

I do have some image files(.png files) in document directory(iPhone). I am viewing web forms(.aspx) on the UIWebView. when I click on the submit button of the form, i just want to attach the image file to the form and wants to send that file to the web server along with the web form.

The thing I m suffering from is, i am not getting how to attach an image file to the web form and how to submit those two.

Kindly help me out of this. I am not getting any of the hint how to do it.

Thanking you….

  • 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-20T12:28:52+00:00Added an answer on May 20, 2026 at 12:28 pm

    You will need to modify these examples to work for you, but they are working examples.

    Objective-C

    MyViewController.m:

    - (void) upload
    {
        NSString *urlString = @"http://www.yourwebsite.com/uploads/upload.php";
        NSData *data = /* turn your png into NSData */
    
        // setting up the request object now
        NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
        [request setURL:[NSURL URLWithString:urlString]];
        [request setHTTPMethod:@"POST"];
        NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
        NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
        [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
    
        /* now lets create the body of the post */
        NSString *content = [NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.png\"\r\n",@"yourPng"];
        NSMutableData *body = [NSMutableData data];
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];    
        [body appendData:[[NSString stringWithString:content] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[[NSString stringWithString:@"Content-Type: text/plain\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[NSData dataWithData:data]];
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
        // setting the body of the post to the reqeust
        [request setHTTPBody:body];
    
        // now lets make the connection to the web
        NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];  
    }
    

    PHP

    upload.php:

    <?php
    //assuming upload.php and upload folder are in the same dir
    $uploaddir = 'uploads/';
    $file = basename($_FILES['userfile']['name']);
    $uploadfile = $uploaddir . $file;
    $product = $_GET[product];
    
    if (is_uploaded_file($_FILES['userfile']['tmp_name']))
    {
        echo "PNG uploaded. \r\n";
    } else {
        echo "PNG not uploaded. \r\n";
    }
    
    if ($_FILES['userfile']['size']> 300000)     //Limiting image at 300K
    {
        exit("Your file is too large."); 
    }
    
    // Add support here for PNG files:
    if ((!($_FILES['userfile']['type'] == "text/plain")) &&  //Also allowing 
        (!($_FILES['userfile']['type'] == "text/plist")) &&  //plist files
        (!($_FILES['userfile']['type'] == "text/html")))     //HTML files
    {
        exit("Incorrect file type.  " . $_FILES['userfile']['type'] . " is the file type you uploaded."); 
    }
    
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        $postsize = ini_get('post_max_size');    //Not necessary, I was using these
        $canupload = ini_get('file_uploads');    //server variables to see what was 
        $tempdir = ini_get('upload_tmp_dir');    //going wrong.
        $maxsize = ini_get('upload_max_filesize');
        echo "http://www.yourwebsite.com/uploads/{$file}" . "\r\n" . $_FILES['userfile']['size'] . "\r\n" . $_FILES['userfile']['type'] ;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a data file and some image files that I have to download
I have some databases that have four files each; one for PRIMARY, IDX, IMAGE,
I have URLs of the form http://domain/image/⟨uuid⟩/42x42/some_name.png . The Web server (nginx) is configured
I have some .swf files I want to use in an iphone app for
I have some scientific image data that's coming out of a detector device in
I have some code that generates image of a pie chart. It's a general
I have a CALayer with some image contents. When a button touched, I want
I have an image(a map) with some points of interest placed using position: absolute
I've some CSS problem in Firefox 3. I have several image buttons on my
Okay so I have two png files, a circle and a maze. Basically the

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.