如何?:
app提交流資訊上傳圖片到server
server端語言php
回複內容:
如何?:
app提交流資訊上傳圖片到server
server端語言php
、、、// 1.設定基準路徑
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/buyer/live/uploadImgs",kUrlPath]]];// 2.初始化請求參數NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];[dict setObject:imageData forKey:@"images"];NSURLRequest *request = [client multipartFormRequestWithMethod:@"POST" path:nil parameters:dict constructingBodyWithBlock:^(id formData) { // 上傳新獲得的圖片檔案 [formData appendPartWithFileData:imageData name:@"imgs_file" fileName:@"hao.png" mimeType:@"image/png"];}];// 發送請求上傳檔案AFHTTPRequestOperation *operation = [client HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];} failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"失敗");}];[operation start];
、、、
可以看下workerman(一個高效能PHP socket伺服器架構),裡面有個例子是接收用戶端傳輸檔案的。