Error when trying to upload image #3806

Closed
opened 2026-02-05 07:31:31 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @j-p-burdell on GitHub (May 16, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hi! I'm new to BookStack and am running into an issue when attempting to upload an image. When attempting troubleshooting/debugging i'm also unable to run the php artisan command.

For the image, i'm trying to upload a png image for my users' Avatar and keep getting the error below. When searching previous Issues looks like this could be related to an ownership or permissions issue. I have tried changing permissions on the uploads and images folders under /config/www but I still get the upload error.

Also, I'm also unable to run php artisan in an attempt to update paths/links in the DB after I changed the APP_URL from http (initial install) to https.

Exact BookStack Version

v23.05.1

Log Content

[2023-05-16 00:57:13] production.ERROR: Error when attempting image upload:Unable to create a directory at /app/www/public/uploads/images/user/2023-05.
[2023-05-16 00:57:13] production.ERROR: File path /uploads/images/user/2023-05/x-men-logo-png-file.png could not be uploaded to. Ensure it is writable to the server. {"userId":3,"exception":"[object] (BookStack\Exceptions\ImageUploadException(code: 0): File path /uploads/images/user/2023-05/x-men-logo-png-file.png could not be uploaded to. Ensure it is writable to the server. at /app/www/app/Uploads/ImageService.php:174)

PHP Version

8.1.2

Hosting Environment

  • Self-hosted
  • Ubuntu 22.04 lxc on Proxmox
  • BookStack running utilizing docker-compose
  • No proxy in use
Originally created by @j-p-burdell on GitHub (May 16, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hi! I'm new to BookStack and am running into an issue when attempting to upload an image. When attempting troubleshooting/debugging i'm also unable to run the php artisan command. For the image, i'm trying to upload a png image for my users' Avatar and keep getting the error below. When searching previous Issues looks like this could be related to an ownership or permissions issue. I have tried changing permissions on the uploads and images folders under <install>/config/www but I still get the upload error. Also, I'm also unable to run php artisan in an attempt to update paths/links in the DB after I changed the APP_URL from http (initial install) to https. ### Exact BookStack Version v23.05.1 ### Log Content [2023-05-16 00:57:13] production.ERROR: Error when attempting image upload:Unable to create a directory at /app/www/public/uploads/images/user/2023-05. [2023-05-16 00:57:13] production.ERROR: File path /uploads/images/user/2023-05/x-men-logo-png-file.png could not be uploaded to. Ensure it is writable to the server. {"userId":3,"exception":"[object] (BookStack\\Exceptions\\ImageUploadException(code: 0): File path /uploads/images/user/2023-05/x-men-logo-png-file.png could not be uploaded to. Ensure it is writable to the server. at /app/www/app/Uploads/ImageService.php:174) ### PHP Version 8.1.2 ### Hosting Environment - Self-hosted - Ubuntu 22.04 lxc on Proxmox - BookStack running utilizing docker-compose - No proxy in use
OVERLORD added the 🐕 Support label 2026-02-05 07:31:31 +03:00
Author
Owner

@ssddanbrown commented on GitHub (May 18, 2023):

Hi @j-p-burdell,

  • How are you attempting to set permission?
  • How are you attempting to run artisan commands?
  • Can you share your docker-compose?
@ssddanbrown commented on GitHub (May 18, 2023): Hi @j-p-burdell, - How are you attempting to set permission? - How are you attempting to run artisan commands? - Can you share your docker-compose?
Author
Owner

@j-p-burdell commented on GitHub (May 18, 2023):

Hi Dan! Thank you for your help and for creating, curating, and maintaining BookStack!

  • For permissions:
    - in /home//docker/bookstack/appconfig/www
    - chmod 777 uploads (i've tried multiple permissions combinations)
    - have also tried changing permissions on the www/files and www/images folders as well

  • For artisan (from /home//docker/bookstack/ where artisan file is located):
    - sudo docker-compose exec bookstack php artisan bookstack:update-url http://:6875 https://:6443
    - get msg of "Could not open input file: artisan"
    - then I tried sudo docker-compose exec php artisan bookstack:update-url http://:6875 https://:6443
    - this didn't throw an error but there was no output either (not sure if that's as expected or not)

  • Docker-compose file:

---
version: "2"
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=https://<FQDN>:6443
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=<secret pw>
      - DB_DATABASE=bookstackapp
    volumes:
      - /home/<user>/docker/bookstack/appconfig:/config
    ports:
      - 6875:6875
      - 6443:6443
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=<super secret pw>
      - TZ=America/New_York
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=<secret pw>
    volumes:
      - /home/<user>/docker/bookstack/dbconfig:/config
    restart: unless-stopped
@j-p-burdell commented on GitHub (May 18, 2023): Hi Dan! Thank you for your help and for creating, curating, and maintaining BookStack! - For permissions: - in /home/<user>/docker/bookstack/appconfig/www - chmod 777 uploads (i've tried multiple permissions combinations) - have also tried changing permissions on the www/files and www/images folders as well - For artisan (from /home/<user>/docker/bookstack/ where artisan file is located): - sudo docker-compose exec bookstack php artisan bookstack:update-url http://<FQDN>:6875 https://<FQDN>:6443 - get msg of "Could not open input file: artisan" - then I tried sudo docker-compose exec php artisan bookstack:update-url http://<FQDN>:6875 https://<FQDN>:6443 - this didn't throw an error but there was no output either (not sure if that's as expected or not) - Docker-compose file: ```yaml --- version: "2" services: bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack environment: - PUID=1000 - PGID=1000 - APP_URL=https://<FQDN>:6443 - DB_HOST=bookstack_db - DB_PORT=3306 - DB_USER=bookstack - DB_PASS=<secret pw> - DB_DATABASE=bookstackapp volumes: - /home/<user>/docker/bookstack/appconfig:/config ports: - 6875:6875 - 6443:6443 restart: unless-stopped depends_on: - bookstack_db bookstack_db: image: lscr.io/linuxserver/mariadb container_name: bookstack_db environment: - PUID=1000 - PGID=1000 - MYSQL_ROOT_PASSWORD=<super secret pw> - TZ=America/New_York - MYSQL_DATABASE=bookstackapp - MYSQL_USER=bookstack - MYSQL_PASSWORD=<secret pw> volumes: - /home/<user>/docker/bookstack/dbconfig:/config restart: unless-stopped ```
Author
Owner

@ssddanbrown commented on GitHub (May 20, 2023):

@j-p-burdell

For permissions:

Read the "User / Group Identifiers" part of the linuxserver container readme for details on doing this properly via the PUID/PGID env options: https://github.com/linuxserver/docker-bookstack/tree/master#user--group-identifiers

For artisan (from /home/<user>/docker/bookstack/ where artisan file is located):

I would not expect artisan to be within your host system at all.
For details on running commands for this container see my video here at about 2:32:
https://youtu.be/6A8hLuQTkKQ?t=152
(Video has loads of other details for managing BookStack in this setup).

@ssddanbrown commented on GitHub (May 20, 2023): @j-p-burdell > For permissions: Read the "User / Group Identifiers" part of the linuxserver container readme for details on doing this properly via the `PUID/PGID` env options: https://github.com/linuxserver/docker-bookstack/tree/master#user--group-identifiers > For artisan (from /home/\<user>/docker/bookstack/ where artisan file is located): I would not expect artisan to be within your host system at all. For details on running commands for this container see my video here at about 2:32: https://youtu.be/6A8hLuQTkKQ?t=152 (Video has loads of other details for managing BookStack in this setup).
Author
Owner

@j-p-burdell commented on GitHub (May 28, 2023):

Thank you @ssddanbrown, much appreciated! Permissions and ownership issues are taken care of and uploads are working :).

That second part regarding spawning a shell in the container is a game changer! For the benefit of others that might run into this issue, here's what I did to get uploads working (Dan - please correct if there are any errors):

  1. Set PUID=1000 and PGID=1000 in the docker-compose.yml file

  2. docker compose up -d

  3. Spawn a shell into the bookstack container:

  • docker compose exec bookstack /bin/bash
  1. Navigate to the app/www directory:
  • cd app/www
  1. List file details to determine name of container user:
  • ls -lah
  1. Set ownership - user discovered in step 5 and www-data as the group:
  • chown -R [container user]:www-data ./
  1. Recursively set permissions for all files:
  • chmod -R 755 ./
  1. Set additional permissions for specific sub-directories:
  • chmod -R 775 bootstrap/cache public/uploads storage
@j-p-burdell commented on GitHub (May 28, 2023): Thank you @ssddanbrown, much appreciated! Permissions and ownership issues are taken care of and uploads are working :). That second part regarding spawning a shell in the container is a game changer! For the benefit of others that might run into this issue, here's what I did to get uploads working (Dan - please correct if there are any errors): 1. Set PUID=1000 and PGID=1000 in the docker-compose.yml file 2. docker compose up -d 3. Spawn a shell into the bookstack container: - docker compose exec bookstack /bin/bash 4. Navigate to the app/www directory: - cd app/www 5. List file details to determine name of container user: - ls -lah 6. Set ownership - user discovered in step 5 and www-data as the group: - chown -R [container user]:www-data ./ 7. Recursively set permissions for all files: - chmod -R 755 ./ 8. Set additional permissions for specific sub-directories: - chmod -R 775 bootstrap/cache public/uploads storage
Author
Owner

@ssddanbrown commented on GitHub (May 30, 2023):

@j-p-burdell Glad to hear that things are working! Will therefore close this off.

@ssddanbrown commented on GitHub (May 30, 2023): @j-p-burdell Glad to hear that things are working! Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3806