SGWiFiUpload is a tool based on CocoaHTTPServer for iOS to upload files through WiFi. By using this framework, you can upload files easily. It can be used for many locations, such as photos and videos upload.Files will save to Caches by default.
- Download SGWiFiUpload and try out the included iPhone example app.
Drag the SGWiFiUpload folder to your project.
#import "SGWiFiUploadManager.h"- (void)setupServer {
SGWiFiUploadManager *mgr = [SGWiFiUploadManager sharedManager];
BOOL success = [mgr startHTTPServerAtPort:10086];
if (success) {
[mgr setFileUploadStartCallback:^(NSString *fileName, NSString *savePath) {
NSLog(@"File %@ Upload Start", fileName);
}];
[mgr setFileUploadProgressCallback:^(NSString *fileName, NSString *savePath, CGFloat progress) {
NSLog(@"File %@ on progress %f", fileName, progress);
}];
[mgr setFileUploadFinishCallback:^(NSString *fileName, NSString *savePath) {
NSLog(@"File Upload Finish %@ at %@", fileName, savePath);
}];
}
[mgr showWiFiPageFrontViewController:self dismiss:^{
[mgr stopHTTPServer];
}];
}You can use the default WiFi Page to tell users how and where to use it.
SGWiFiUploadManager *mgr = [SGWiFiUploadManager sharedManager];
[mgr showWiFiPageFrontViewController:self dismiss:^{
[mgr stopHTTPServer];
}];You can change the file save location by change the value of savePath in SGWiFiUploadManager.
You can change the file save location by change the value of webRoot in SGWiFiUploadManager, the server will search index.html and upload.html in this path.
You can change the count of files to upload by modify the index.html in Web Folder.
You can add input tag with type="file" in the form whose action is upload.html and method is POST.