This commit is contained in:
Pierre-Olivier Latour
2014-04-26 19:30:18 -07:00
parent ed709d1476
commit c8c34aa61f
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -278,7 +278,9 @@ int main(int argc, const char* argv[]) {
} }
for (GCDWebServerMultiPartFile* file in [(GCDWebServerMultiPartFormRequest*)request files]) { for (GCDWebServerMultiPartFile* file in [(GCDWebServerMultiPartFormRequest*)request files]) {
NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file.temporaryPath error:NULL]; NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file.temporaryPath error:NULL];
[string appendFormat:@"%@ = &quot;%@&quot; (%@ | %llu KB)<br>", file.controlName, file.fileName, file.mimeType, attributes.fileSize / 1000]; [string appendFormat:@"%@ = &quot;%@&quot; (%@ | %llu %@)<br>", file.controlName, file.fileName, file.mimeType,
attributes.fileSize >= 1000 ? attributes.fileSize / 1000 : attributes.fileSize,
attributes.fileSize >= 1000 ? @"KB" : @"Bytes"];
}; };
NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p><hr>%@</body></html>", string, formHTML]; NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p><hr>%@</body></html>", string, formHTML];
return [GCDWebServerDataResponse responseWithHTML:html]; return [GCDWebServerDataResponse responseWithHTML:html];
+2 -2
View File
@@ -1,9 +1,9 @@
HTTP/1.1 200 OK HTTP/1.1 200 OK
Cache-Control: no-cache Cache-Control: no-cache
Content-Length: 443 Content-Length: 447
Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8
Connection: Close Connection: Close
Server: GCDWebServer Server: GCDWebServer
Date: Fri, 25 Apr 2014 14:15:21 GMT Date: Fri, 25 Apr 2014 14:15:21 GMT
<html><body><p>secret = 42<br>files = &quot;hero_mba_11.jpg&quot; (image/jpeg | 106 KB)<br>files = &quot;Test File.txt&quot; (text/plain | 0 KB)<br></p><hr> <form name="input" action="/" method="post" enctype="multipart/form-data"> <input type="hidden" name="secret" value="42"> <input type="file" name="files" multiple><br/> <input type="submit" value="Submit"> </form> </body></html> <html><body><p>secret = 42<br>files = &quot;hero_mba_11.jpg&quot; (image/jpeg | 106 KB)<br>files = &quot;Test File.txt&quot; (text/plain | 21 Bytes)<br></p><hr> <form name="input" action="/" method="post" enctype="multipart/form-data"> <input type="hidden" name="secret" value="42"> <input type="file" name="files" multiple><br/> <input type="submit" value="Submit"> </form> </body></html>