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)
35 strcpy(WC->ImportantMessage, &buf[4]);
39 output_headers(1, 1, 0, 0, 0, 0, 0);
41 svprintf("BOXTITLE", WCS_STRING, "Set/change your photo");
42 do_template("beginbox");
44 wprintf("<CENTER>\n");
46 wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" "
47 "METHOD=\"POST\" NAME=\"graphicsupload\">\n", uplurl);
49 wprintf("<INPUT TYPE=\"hidden\" NAME=\"which_room\" VALUE=\"");
50 urlescputs(bstr("which_room"));
53 wprintf("You can upload any image directly from your computer,\n");
54 wprintf("as long as it is in GIF format (JPEG, PNG, etc. won't\n");
55 wprintf("work).<br /><br />\n");
57 wprintf("Please select a file to upload:<br /><br />\n");
58 wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
59 wprintf("<br /><br />");
60 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Upload\">\n");
62 wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
64 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Cancel\">\n");
66 wprintf("</CENTER>\n");
67 do_template("endbox");
71 void do_graphics_upload(char *upl_cmd)
78 if (!strcasecmp(bstr("sc"), "Cancel")) {
79 strcpy(WC->ImportantMessage,
80 "Graphics upload cancelled.");
85 if (WC->upload_length == 0) {
86 strcpy(WC->ImportantMessage,
87 "You didn't upload a file.");
94 strcpy(WC->ImportantMessage, &buf[4]);
98 bytes_remaining = WC->upload_length;
99 while (bytes_remaining) {
100 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
101 serv_printf("WRIT %d", thisblock);
104 strcpy(WC->ImportantMessage, &buf[4]);
110 thisblock = extract_int(&buf[4], 0);
111 serv_write(&WC->upload[pos], thisblock);
112 pos = pos + thisblock;
113 bytes_remaining = bytes_remaining - thisblock;
119 display_success(&buf[4]);