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 format (JPEG, PNG, etc. won't "
39 wprintf("<br /><br />\n");
41 wprintf(_("Please select a file to upload:"));
42 wprintf("<input type=\"file\" name=\"filename\" size=\"35\">\n");
43 wprintf("<div class=\"buttons\">");
44 wprintf("<input type=\"submit\" name=\"upload_button\" value=\"%s\">\n", _("Upload"));
46 wprintf("<input type=\"reset\" value=\"%s\">\n", _("Reset form"));
48 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
52 do_template("endbox");
57 void do_graphics_upload(char *upl_cmd)
64 if (!IsEmptyStr(bstr("cancel_button"))) {
65 strcpy(WC->ImportantMessage,
66 _("Graphics upload has been cancelled."));
71 if (WC->upload_length == 0) {
72 strcpy(WC->ImportantMessage,
73 _("You didn't upload a file."));
78 serv_getln(buf, sizeof buf);
80 strcpy(WC->ImportantMessage, &buf[4]);
84 bytes_remaining = WC->upload_length;
85 while (bytes_remaining) {
86 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
87 serv_printf("WRIT %d", thisblock);
88 serv_getln(buf, sizeof buf);
90 strcpy(WC->ImportantMessage, &buf[4]);
92 serv_getln(buf, sizeof buf);
96 thisblock = extract_int(&buf[4], 0);
97 serv_write(&WC->upload[pos], thisblock);
98 pos = pos + thisblock;
99 bytes_remaining = bytes_remaining - thisblock;
103 serv_getln(buf, sizeof buf);
105 display_success(&buf[4]);