BookStackApp/BookStack · error · Error

Not an image file

Error message

Not an image file

What it means

Guard in the legacy TinyMCE editor's uploadImageFile rejecting a File that is null or has a non-image MIME type, so paste/drop handling only uploads actual images. Input at fault: the pasted or dropped file whose type does not start with 'image'.

Solutions

  1. Check file.type starts with 'image' before calling uploadImageFile
  2. Notify the user that only image files can be pasted/dropped as images
  3. Handle empty browser file.type with an extension-based fallback check
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at resources/js/wysiwyg-tinymce/drop-paste-handling.js:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/3d51e4c0c45bb971. Report an issue: GitHub.

Appendix: source

Thrown at resources/js/wysiwyg-tinymce/drop-paste-handling.js:17

import {Clipboard} from '../services/clipboard.ts';

let wrap;
let draggedContentEditable;

function hasTextContent(node) {
    return node && !!(node.textContent || node.innerText);
}

/**
 * Upload an image file to the server
 * @param {File} file
 * @param {int} pageId
 */
async function uploadImageFile(file, pageId) {
    if (file === null || file.type.indexOf('image') !== 0) {
        throw new Error('Not an image file');
    }

    const remoteFilename = file.name || `image-${Date.now()}.png`;
    const formData = new FormData();
    formData.append('file', file, remoteFilename);
    formData.append('uploaded_to', pageId);

    const resp = await window.$http.post(window.baseUrl('/images/gallery'), formData);
    return resp.data;
}

/**
 * Handle pasting images from clipboard.
 * @param {Editor} editor
 * @param {WysiwygConfigOptions} options
 * @param {ClipboardEvent|DragEvent} event
 */
function paste(editor, options, event) {

View on GitHub (pinned to 18f8469a1c)