4 * Handles HTTP upload of graphics files into the system.
5 * \ingroup WebcitHttpServer
10 void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
15 serv_getln(buf, sizeof buf);
17 strcpy(WC->ImportantMessage, &buf[4]);
21 output_headers(1, 1, 0, 0, 0, 0);
23 output_headers(1, 1, 1, 0, 0, 0);
25 svprintf("BOXTITLE", WCS_STRING, _("Image upload"));
26 do_template("beginbox");
28 wprintf("<form enctype=\"multipart/form-data\" action=\"%s\" "
29 "method=\"post\" name=\"graphicsupload\">\n", uplurl);
31 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
32 wprintf("<input type=\"hidden\" name=\"which_room\" value=\"");
33 urlescputs(bstr("which_room"));
36 wprintf(_("You can upload any image directly from your computer, "
37 "as long as it is in GIF, JPEG or PNG"));
38 wprintf("<br /><br />\n");
40 wprintf(_("Please select a file to upload:"));
41 wprintf("<input type=\"file\" name=\"filename\" size=\"35\">\n");
42 wprintf("<div class=\"buttons\">");
43 wprintf("<input type=\"submit\" name=\"upload_button\" value=\"%s\">\n", _("Upload"));
45 wprintf("<input type=\"reset\" value=\"%s\">\n", _("Reset form"));
47 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
51 do_template("endbox");
56 void do_graphics_upload(char *upl_cmd)
63 if (!IsEmptyStr(bstr("cancel_button"))) {
64 strcpy(WC->ImportantMessage,
65 _("Graphics upload has been cancelled."));
70 if (WC->upload_length == 0) {
71 strcpy(WC->ImportantMessage,
72 _("You didn't upload a file."));
77 serv_getln(buf, sizeof buf);
79 strcpy(WC->ImportantMessage, &buf[4]);
83 bytes_remaining = WC->upload_length;
84 while (bytes_remaining) {
85 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
86 serv_printf("WRIT %d", thisblock);
87 serv_getln(buf, sizeof buf);
89 strcpy(WC->ImportantMessage, &buf[4]);
91 serv_getln(buf, sizeof buf);
95 thisblock = extract_int(&buf[4], 0);
96 serv_write(&WC->upload[pos], thisblock);
97 pos = pos + thisblock;
98 bytes_remaining = bytes_remaining - thisblock;
102 serv_getln(buf, sizeof buf);
104 display_success(&buf[4]);