4 * Handles HTTP upload of graphics files into the system.
13 #include <sys/types.h>
15 #include <sys/socket.h>
18 #include <netinet/in.h>
28 void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
33 serv_getln(buf, sizeof buf);
35 strcpy(WC->ImportantMessage, &buf[4]);
39 output_headers(1, 1, 0, 0, 0, 0, 0);
41 output_headers(1, 1, 2, 0, 0, 0, 0);
42 wprintf("<div id=\"banner\">\n"
43 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
44 "<SPAN CLASS=\"titlebar\">Image upload</SPAN>"
45 "</TD></TR></TABLE>\n"
46 "</div>\n<div id=\"content\">\n"
49 wprintf("<div id=\"fix_scrollbar_bug\">"
50 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
52 wprintf("<CENTER>\n");
54 wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" "
55 "METHOD=\"POST\" NAME=\"graphicsupload\">\n", uplurl);
57 wprintf("<INPUT TYPE=\"hidden\" NAME=\"which_room\" VALUE=\"");
58 urlescputs(bstr("which_room"));
61 wprintf("You can upload any image directly from your computer,\n");
62 wprintf("as long as it is in GIF format (JPEG, PNG, etc. won't\n");
63 wprintf("work).<br /><br />\n");
65 wprintf("Please select a file to upload:<br /><br />\n");
66 wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
67 wprintf("<br /><br />");
68 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Upload\">\n");
70 wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
72 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Cancel\">\n");
74 wprintf("</CENTER>\n");
75 wprintf("</td></tr></table></div>\n");
79 void do_graphics_upload(char *upl_cmd)
86 if (!strcasecmp(bstr("sc"), "Cancel")) {
87 strcpy(WC->ImportantMessage,
88 "Graphics upload cancelled.");
93 if (WC->upload_length == 0) {
94 strcpy(WC->ImportantMessage,
95 "You didn't upload a file.");
100 serv_getln(buf, sizeof buf);
102 strcpy(WC->ImportantMessage, &buf[4]);
106 bytes_remaining = WC->upload_length;
107 while (bytes_remaining) {
108 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
109 serv_printf("WRIT %d", thisblock);
110 serv_getln(buf, sizeof buf);
112 strcpy(WC->ImportantMessage, &buf[4]);
114 serv_getln(buf, sizeof buf);
118 thisblock = extract_int(&buf[4], 0);
119 serv_write(&WC->upload[pos], thisblock);
120 pos = pos + thisblock;
121 bytes_remaining = bytes_remaining - thisblock;
125 serv_getln(buf, sizeof buf);
127 display_success(&buf[4]);