ASIHTTPRequest - Specifying the file to post data to
The following example is given on the ASI website:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setP开发者_如何学GoostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];
Where do you specify the file to post the data to? I have a php file which is expecting the posted data...
Forgive me, I am new to iPhone development..
It's the url that you passed in [ASIFormDataRequest requestWithURL:url]
.
NSString *myphp = @"http://www.mysite.com/myscript.php";
NSURL *url = [NSURL URLWithString:myphp];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
If you just want to post first name and last name then below code doesn't work. I think if you remove setFile method then it should just post first name and last name ?
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
Hope this help.
精彩评论