IPhone Development notes (11) Use asiformdatarequest to upload images

Source: Internet
Author: User

Asiformdatarequest is an important part of the asihttprequest class library. You need to take photos of your iPhone and then upload the photos to the server. The following figure shows how to use asiformdatarequest to upload images in post mode on the IOS client:

Nsstring * filename = [[nsbundle mainbundle] pathforresource: @ "test" oftype: @ "jpg"]; nsstring * url = @ "http ://...... /upload. aspx "; asiformdatarequest * request = [asiformdatarequest requestwithurl: [nsurl urlwithstring: url]; [Request setpostvalue: @" myname "forkey: @" name "]; [Request setfile: filename forkey: @ "this_is_file"]; [Request buildrequestheaders]; nslog (@ "header: % @", request. requestheaders); [Request startsynchronous]; nslog (@ "responsestring = % @", request. responsestring );

In the next article, I will use. Net to enable the server to receive images and save them to a specific path on the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.