PageSourceSearch

https://blackbusinessmonth.com/assets/upload-test-C6BMN4RN.js

js blackbusinessmonth.com collected 2026-09-24 23:51:03 UTC 3,201 bytes, 77 lines download raw bytes

1import { r as reactExports, j as jsxRuntimeExports } from "./vendor-BnxyTOIt.js";
2import "./preload-VwzZcMtp.js";
3function UploadTest() {
4  const [uploading, setUploading] = reactExports.useState(false);
5  const [result, setResult] = reactExports.useState("");
6  const fileInputRef = reactExports.useRef(null);
7  const handleUpload = async (e) => {
8    var _a;
9    e.stopPropagation();
10    e.preventDefault();
11    const file = (_a = e.target.files) == null ? void 0 : _a[0];
12    if (!file) return;
13    const fileToUpload = file;
14    setUploading(true);
15    setResult("Uploading...");
16    try {
17      const fd = new FormData();
18      fd.append("photo", fileToUpload);
19      console.log("Sending upload request...");
20      const res = await fetch("/api/upload", {
21        method: "POST",
22        body: fd
23      });
24      console.log("Response:", res.status, res.ok);
25      const data = await res.json();
26      console.log("Data:", data);
27      if (data.url) {
28        setResult(`SUCCESS! Photo uploaded: ${data.url}`);
29      } else if (data.error) {
30        setResult(`ERROR: ${data.error}`);
31      }
32    } catch (err) {
33      console.error("Upload error:", err);
34      setResult(`EXCEPTION: ${err instanceof Error ? err.message : "Unknown error"}`);
35    } finally {
36      setUploading(false);
37      if (fileInputRef.current) {
38        fileInputRef.current.value = "";
39      }
40    }
41  };
42  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
43    padding: "40px",
44    fontFamily: "sans-serif"
45  }, children: [
46    /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { children: "Upload Test Page" }),
47    /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "This is a simple test to verify uploads work." }),
48    /* @__PURE__ */ jsxRuntimeExports.jsx("input", { ref: fileInputRef, type: "file", onChange: handleUpload, accept: "image/*", disabled: uploading, style: {
49      marginTop: "20px",
50      padding: "10px",
51      border: "1px solid #ccc"
52    } }),
53    result && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: {
54      marginTop: "20px",
55      padding: "15px",
56      background: result.startsWith("SUCCESS") ? "#d4edda" : "#f8d7da",
57      border: `1px solid ${result.startsWith("SUCCESS") ? "#c3e6cb" : "#f5c6cb"}`,
58      borderRadius: "4px"
59    }, children: result }),
60    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
61      marginTop: "20px",
62      fontSize: "12px",
63      color: "#666"
64    }, children: [
65      /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "Instructions:" }) }),
66      /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { children: [
67        /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: 'Click "Choose File" and select an image' }),
68        /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "Watch the console (F12 → Console tab) for detailed logs" }),
69        /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "If it works here, the problem is in the admin UI code" }),
70        /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "If it fails here, the problem is in the server or network" })
71      ] })
72    ] })
73  ] });
74}
75export {
76  UploadTest as default
77};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.