1

I am having the problem while uploading the media file in wordpress. While uploading the media file instead of saving it to folder wp-content/uploads/2016/07/ it's uploading to the folder wp-content/uploads/2013/01 with the permission 644.

I have tried by changing the permission of the wp-content/ and uploads/ to 755 and 777 recursively as well. But no any progess.

PS: I am trying to upload the file from media of wordpress dashboard not from any post so that we call it a feature.

KCP
  • 929
  • 9
  • 29

2 Answers2

2

1) Try printing the wp_upload_dir() function in one of your templates so you can see what's going on under the hood: <?php print_r(wp_upload_dir()); ?>

This output an array that looks something like this:

Array ( [path] => /root/of/site/wp-content/uploads/2016/07 [url] => http://whatever.com/wp-content/uploads/2016/07 [subdir] => /2016/07 [basedir] => /code/wp-content/uploads [baseurl] => http://whatever.com/wp-content/uploads [error] => )

2) If that path is wrong, you need to reset it. Check in your wp-config.php and see if you are redirecting the default download folder to something custom. Look for this line of code: define('UPLOADS', 'custom/path/here');

If you don't see this line of code, put it in there and set it to whatever you want.

3) You can override the behavior you are seeing with plugins. My favorite is called Custom Upload Dir: https://wordpress.org/plugins/custom-upload-dir/. Search around a bit, there are a number of similar plugins for you to try.

serraosays
  • 7,163
  • 3
  • 35
  • 60
  • 1) There isn't any line define('UPLOADS', 'custom/path/here'); in wp-config.php file. 2) Ya, Using plugin is also one of the method to do that. But I perfer to use the default one which is having this weird issue. – KCP Jul 29 '16 at 16:05
  • Put a default wp-config.php in there, see what happens. It's almost got to be that or some server setting. – serraosays Jul 29 '16 at 17:18
  • Replacing with default wp-config.php also didn't work out. I am not getting any idea what's the actual problem. Can you please tell me what might be the problem in server settings? – KCP Jul 29 '16 at 19:41
  • @KCP - I tried putting more info in here for you. Try this stuff. – serraosays Jul 29 '16 at 20:30
  • I tried printing the wp_upload_dir(). And the result is: Array ( [path] => /root/of/site//wp-content/uploads/2016/07 [url] => site.com/wp-content/uploads/2016/07 [subdir] => /2016/07 [basedir] => /root/of/site/wp-content/uploads [baseurl] => site.com/wp-content/uploads [error] => ) From this, I guess the path is correct. But then too it's going to 2013/01/ folder. – KCP Jul 31 '16 at 17:51
  • So WordPress is setup correctly. There has to be something going on with your server. Try putting the code on a different local machine - it should work correctly. – serraosays Aug 01 '16 at 12:46
1

Did you check your server's system date? Also did you correctly set the permissions for the owner and group of the web root before recursively setting the permissions of the directories and files therein?

Jon Wilson
  • 86
  • 6
  • There isn't any problem with the server's system date. Ya, I did set the permissions for the owner and the group of the web root correctly. – KCP Jul 29 '16 at 16:02