0

How to send image data to server? (I already have a sample page)

Sample Page html Source Code

<form action="/uploadfile.html" method="post"
    enctype="multipart/form-data" onSubmit="return validate();">

    <fieldset><legend>Upload File</legend>
    <table>
        <tr>
            <td><input name="fileData" id="image" type="file" /></td>
        </tr>
        <tr>
            <td><br />
            </td>
            <td><input type="submit" value="Upload" /></td>
        </tr>
    </table>
    </fieldset>
</form>

It works fine on web page. (File Name: 1234.png) This server check file name and save specific DB.

Example (These work very well on web page *http://SAMPLE_PAGE.com/uploadfile.html*)

1234.png or 5678.png =upload=> save to number.db
abcd.png or wxyz.png =upload=> save to alphabet.db

I must upload via iOS and I have a data object (imgData).

NSData *imgData; //  Image Data
NSString *wantedFileName = @"1234.png";

How to upload to server via iOS Device? (like sample web-page)

ChangUZ
  • 5,380
  • 10
  • 46
  • 64

1 Answers1

0

When we want to upload any file on server using some application we can use multi-part request for this. In this we create a NSURLMutableRequest object with multipart body having desired data.

You can visit following links for a pointer: send image to server in multipart iphone

Sending multipart request from iPhone to Ruby on Rails (RoR) server

Community
  • 1
  • 1
Ravin
  • 8,544
  • 3
  • 20
  • 19