Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Basics Managing Media in WordPress Image Galleries in WordPress

Sarah Degros
Sarah Degros
6,760 Points

Unable to upload media

Hello,

I hope this message finds you well.

I donloaded the latest version of WP

I use MAMP

I am on Windows 10

When I try to upload images, I am facing this error message :

"The uploaded file could not be moved to wp-content/uploads/2019/02."

I have tried and tried and tried....

Can someone please help me with that ?

Regards, Sarah

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Have you checked your permissions (need the ability to create folders)?

Also if you don't want all those separate folders for your uploads (I think it's a pain unless you have a large active site with many contributors) your can go to settings/media and uncheck the box next to - Organize my uploads into month- and year-based folders

3 Answers

Sarah Degros
Sarah Degros
6,760 Points

Hi Dave,

Thank you so much for your help.

I am a newbie in development and wordpress, so my questions may seem really basic, sorry for that.

I followed your advice regarding the subfolders, thank you for that.

Regarding the permissions, in phpMyAdmin, I already granted "all privileges" to the user (I am the user of course)...

I still have the same error message.

I am lost...

I would be really grateful for any help.

Regards Sarah

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Hi Sarah,

Don't worry about being lost, that's the fun part hehe...

I think you are confusing the permissions since there are multiple moving parts here. phpMyAdmin is for your MySQL database - and you should be all set there if you were able to install wordpress.

We are now talking about permissions to your file system - your document root (maybe htdocs or public_html or something like that) where you put the wordpress files (folders like wp-admin, wp-content ...).

The uploads folder is usually a sub folder of wp-content and the user that is trying to place your uploaded file is actually apache (the web server) not you. This is key to understand. I'm not on a mac and believe that it was once "_www". So, you need to set permissions to the apache user.

I'm not on a mac using MAMP - so this tutorial might help.

Does that get you rolling?

Dave :tropical_drink: :palm_tree:

Sarah Degros
Sarah Degros
6,760 Points

Hi Dave,

Thank you so much for your answer !!

So, my understanding is that I need to give Apache permissions to my wp-content folder, right ?

I carefully read the tutorial you linked in your answer

However, Putty displays this error message "server unexpectedly closed network connection"

  • HOST NAME : localhost
  • PORT : 81
  • CONNECTION TYPE : SSH

I tried different solutions suggested on Stackoverflow like acivating "Enable TCP keepalives" and giving different values to "seconds between keepalives", it still does not work

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Hi Sarah,

Sorry for the confusion, let me try to clear things up a bit.

That tutorial is generic and the putty stuff is for the unfortunate windows users trying to access their site on a shared hosting service. Putty is basically providing a terminal session for windows. You have terminal on a Mac so will not need putty. Also, since you are local you don't need to ssh into your own machine - so ignore that stuff.

Back to our goal :smile: - We need to find out the apache user to know who's permissions need updating.

So, make sure your MAMP apache server is active.

Then in your local Mac terminal - enter the command ps aux - this will show all the active running processing. Since there are so many, We'll use grep to filter just the apache ones.

Now enter ps aux | grep -i apache

Now you should 5 to 10 entries (including one with your user name showing the grep command you entered) You should also see a user name like "_www" or something similar (for me on Ubuntu it is "www-data".). This will the name we need. It should also be listed in your users admin dialogue along with being a member of a group with the same name.

From everything I've seen, other mamp users say their apache user is _www - so I'll use that in the examples below...

Since you are probably anxious to get rolling you should be able go to finder and add the user like _www to all folders subfolder and files in your document root (or even just wp-content and it's subfolders).

When you're ready to take the next step and follow best practices. I would recommend setting (yes, a lot of fun stuff to learn).

I would recommend that you add your user to the _www group and set that group as the owner of everything in your document root on down.

You should also become a regular visitor to the WordPress Codex and also checkout their Hardening WordPress Info to do the WP way.

Hope that's not even more confusing and it really does get easier :smile:

Sarah Degros
Sarah Degros
6,760 Points

Hi Dave,

Thank you again for your time and help.

I think there is a misunderstanding, I am not working on a Mac but I am working on Windows 10 :)

I wrote it in my first post but I am really sorry if this wasn't clear enough

:)

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Well Sarah, sorry, I saw mamp and thought it was mac. I didn't know mamp could run on windows - it used to be that you the m in mamp was for mac and you used Wamp on windows. (learn something new every day) - you were clear enough, I just jumped to conclusions.

I do have a win10 lappy so I'm installing and will update you - my mamp is running under my username - will update once I get WP installed and attempt an upload.

Dave

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Well - I installed mamp and didn't have any issues uploading a pic.

Apache (and MySQL) are running in task manager as my user. Also, I an administrator on my machine.

Did you click "Allow Access" for Apache and MySQL when starting mamp? Is your user Admin? Are you attempting to add images using dashboard/media/add new? Have you rebooted and restarted the mamp servers?

I would still double verify the permissions for your user.

Anyway, sorry for sending you down the wrong rabbit holes.

Maybe post new question to get new responses from smarter peeps.

Or even try uninstalling and starting over and/or checking out wamp or xampp - a couple of other options out there.