Can JSON Framework be used to upload files to a website like ASIHTTPREQUEST
I want to download some files from my website and have to upload the mod开发者_Go百科ified files into the website. The downloading can be done fine with JSON Frame work. Now I want to know whether I can use this Frame work to upload my files too. If yes please give me some sample application to help me with this.
You an try the following for posting data to remote php server.
NSString *jsonString = [self.dataSource JSONRepresentation];
NSURL *url = [NSURL URLWithString:@"http://remoteserver.com/test.php"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request appendPostData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
[request startSynchronous];
精彩评论