I've changed the default WordPress media upload dir (http://example.com/wp-content/uploads) to (http://example.com/uploads). Everything is OK and media files are uploading and showing correctly. But when I use get_attached_file
function to get the path of the file (e.g. http://example.com/uploads/hello.jpg
), it returns the wrong path ( in this case: home/username/public_html/wp-content/uploads/hello.jpg
).
So when I call the file_get_contents
with this path, I get failed to open stream no such file or directory
error!
How can I fix this problem?
1 Answer
I found the problem :) Actually this is my friend's website. I don't have any idea how he changed the upload dir but I noticed that there is no define( 'UPLOADS', ''.'uploads' );
in his wp-config.php
file. I added it and it's now working perfectly. I hope this helps other people who will facing this problem.