Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't uplaod images to Wordpress #30

Open
eliawk opened this issue Jun 4, 2019 · 3 comments
Open

Can't uplaod images to Wordpress #30

eliawk opened this issue Jun 4, 2019 · 3 comments

Comments

@eliawk
Copy link

eliawk commented Jun 4, 2019

Hello,
I actually can't upload any images to Wordpress due a permissione limitation.
Schermata 2019-06-04 alle 12 35 40
could you please help me?

thaks

@PutziSan
Copy link
Contributor

For me, the problem occurs at windows and is generally known. This is also the same problem that plugins, themes and wordpress cannot be updated or reinstalled, at least for me.

There are many solutions that can be found in many issues, but finding the right solution was quite hard.

Adding user: root to the wordpress entry in docker-compose.yml worked for me:

# ...
  wordpress:
    user: root
# ...

Also, in the Docker settings, your drive must be shared as a shared drive. If it's already enabled, it's worth using Reset credentials to re-enter your username and password. There may also be problems with an online windows account and you may need to set up an additional local one. This is well explained here.

@willtonkin
Copy link

I'm not sure how this was to work before, as the state of the uploads directory appears to not be persisted outside of the container. After adding the uploads dir to the volumes list, this resolved the problem for me:
under docker-compose.yaml:24:

      - "./.data/uploads:/var/www/html/wp-content/uploads"

@ivanstame
Copy link

ivanstame commented Oct 12, 2020

Uploading images on a docker container for a web project is potentially a total dumpster fire. There will be more
errors than your sanity can handle. So let's get going with the first one.

Congratulations! Your ass doesn't have an uploads folder in the project itself. This has to
be done in the docker-compose file to set everything up from the get-go, so let's do that. Add
this baby to volumes in the wordpress container:

- "./.data/uploads:/var/www/html/wp-content/uploads"

Sick, now we're cooking with gas. Haha yeah right, bro you have no idea how many character building
errors await you. Go on ahead and try to upload something...I'll wait. You back yet? Yeah,
how'd that go? Not so well right? Let me guess you probably got something like this nightmare didn't
you?

Unable to Create Directory wp-content/uploads. Is its Parent Directory Writable by the Server in WordPress

Let's kill this thing shall we? Onward!

So to tackle this shart we are going to need to get inside the container itself via terminal.
In order to do this you need to run the following command in your linux machine's terminal:

sudo docker container exec -it {container-name} bash

Ok we're in.... now what amiright?! Alright calm down. Now that we're in, we have to
install a text editor inside it, because this container is basic AF. Like I'm talking no
power windows at all, just that practical little roll up handle.

apt-get update
apt-get install nano

Sick, now you have nano and we are ready to do some damage. Ok, let's find the wp-config.php
file. You should be inside the root of the wp folder of the container, something like:
/var/www/html or something like that. So:

nano wp-config.php

Now, scroll that bad boy all the way to the bottom until you see this line:

require_once(ABSPATH . 'wp-settings.php');

Right above that ish you need to add this:

define( 'UPLOADS', 'wp-content/uploads' );

Ok, CTL-O, Enter, and then CTL-X. Presto! Fuckin done right? Nope, one more error lies ahead.
But don't take my word for it, go on and try to upload something. What error did you get?
Let me guess, it was this absolute gem wasn't it?:

The uploaded file could not be moved to wp-content/uploads/

Yup, hopefully you haven't jumped out of your second story window yet. Hope is just around
the corner, we are almost done homie g-funk. Ready? Of course you're not, but who gives a
fack? Let's do this.

Ok so, we need to be inside that lovely container, and at this point you probably still have
that shit open...along with like eight tabs from pornhub to settle down the anger and
frustration brought about by the unholy marriage between docker and wordpress. Bookmark those
tabs and put that thing away, time is of the essence. Do the following and you are home free:

PS. www-data is the user that web servers on Ubuntu use by default

cd wp-content
chown -R www-data:www-data uploads
chmod 755 uploads

And bam! You did it homeboy. At ease soldier. Enjoy those crisp uploads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants