Wordpress upload folder permissions 751 - php

I want to protect my images on my wordpress site. So I changed the folder permissions of the following folders to 751:
wp-content/uploads
wp-content/uploads/2018
wp-content/uploads/2018/11
However, now when I upload an image via the Media upload, the image is not shown.
Is there any way to keep 403 Error for the above folders while still being able to upload and see the images correctly in the wp-backend?
I know this can be done, because Ive seen this before, I just dont know how to apply it myself.
Any help is greatly appreciated

A better to do this is to simply add the following code to the bottom of your .htaccess file:
Options -Indexes
And you can keep your folder permission to the default 755 and not have to access your cpanel every time you upload a file.

I figured how to do this, but only know how to do it manually.
Part A.
Set permissions to 751 for the following folders:
wp-content/uploads
wp-content/uploads/2018
wp-content/uploads/2018/11
Every month, and year, you need to apply the settings for the new months folder.
Part B.
Upload images in the wordpress backend using media uploader. (Dont worry you cant see the images yet)
Then, in cpanel, go to the folder where those files have uploaded
Next, for all those files you uploaded, change permissions to 644 (it should have been 640 right after you uploaded them)

Related

How should i save photos with php/apache?

My question is, where should i save photos that will be uploaded from the users?
my root dir for the server is
C:/apache
here i have the folder that contains the php files C:/apache/htdocs . I was wondering where should i save the files, i heard it will be better if i saved it somewhere else than the htdocs (folder that contains the php scripts), but here is the thing. If i save it directly to C:/apache then i can't access the photos. While saving it to a new folder in C:/apache/htdocs/photos would make the photos folder visible or accesible from the php pages. Is there a way i can save them somewhere else, like, let's say one folder up from the htdocs folder?
EDIT: the .htaccess seems like a good solution. Though i'm curious about this 1 thing:
I was thinking, is it possible to have directories something like this?
--->phpfiles
|--->index.php
|--->another.php
--->photos
|--->1.jpg
|--->etc.jpg
And still somehow link those photos to my php files? Like making the server only view the phpfiles folder for links and all of that (so i can go to localhost/index.php and not localhost/phpfiles/index.php ) ?
EDIT 2: My server root is C:/apache, while my Document Root is C:/apache/htdocs. in case of any misunderstanding, sorry
I would suggest putting the uploads in a folder like you suggested with C:/apache/htdocs/photos and place a .htaccess in that file that prevents direct access to the folder. That way the folder won't be visible and they can't access the images without the file name.
Another solution would be to upload the images on a third party server.

Media isn't showing in Wordpress library but is available in uploads folder

I am trying to migrate my site from shared hosting to the digital ocean.
I have uploaded wp-content and my site is over 3 years old.
Now when I am checking into the media on the dashboard.
Files aren't showing. Ideally, all the months should be visible but as you can see in the image only selected no of months are shown.
How can I get the Wordpress to show all the months and images? enter image description here
Let me know, if it works or not!
The image that is not showing for me has this location!
wp-content/uploads/2019/02/spring.png
I have to check, Whether the permission for uploads folder, 2019 folder and then for
02 folder are same or not
Go to your wp-content folder
Then check each folder permission they have to be the same!
In my case they are same now go to your database and delete the upload path in your
wp-database option
Go to wp-options and look for upload path, it can be on the second page also, search
for it
cut the path and paste it somewhere else, and make the path empty
Now upload and image again to see if it is showing in media library or not.

Images not displaying in wordpress

So for some reason my images are just showing a broken image icon when I open my website from the adminpanel in WP. But when I open the index.php file the images are showing just as I want them to. Same with my javascript.
I have linked the image directory correctly since they are showing up when I only open the index.php file. They are also in the media library in wordpress.
Maybe a simpler explanation is:
localhost/website/wordpress = no images, only broken image icons.
localhost/website/wordpress/wp-content/themes/mywebsite/index.php = the images are showing.
EDIT: I found out you could copy the link that wordpress gives you for every image, and that made it work.
Is that the only way of doing it or is there another way?
Check is your .htaccess file for rules applied to images or image folder. Rename it to be sure
Remove image related wordpress plugins like "Adaptive Images"
It may due to file accessibility permission issue. Just give permission to your image folder. check your .htaccess file (on root).
Install a file browsing plugin or directly go to the hosted site and edit the .htaccess file. Add the folder name on the file

Could not create the index.html file - TimThumb

I am using TimThumb version : 2.8.14.
After moving site on UAT server its stopped working.
It's show following error.
Could not create the index.html file - to fix this create an empty
file named index.html file in the cache directory. Could not create
cache clean timestamp file.
I have tried some solutions like folder permission and all but still not luck. Issue still coming.
Is this issue from server side ?
Look in your timthumb-config.php, to check if the FILE_CACHE_DIRECTORY is set to the directory you think it is.
You could also delete the existing index.html file that's in the tim thumb cache directory, as tim thumb will automatically create it
You may also need to check the config file to see if the MEMORY_LIMIT is set high enough for your particular images.
Timthumb can't show image after it's uploaded

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

While using the 'Ultimate Members' plugin, I am receiving the following error when trying to upload media to my wordpress website:
The uploaded file could not be moved to wp-content/uploads/2018/09.
This error could be caused by a few things;
Permissions is the most probable answer, your plugin might not have the correct permissions to upload your contents folder.
You will need to go into your file system and change the wp-contents folder and everything within it to 744. If this doesn't work, try 755.
Hope this helps!

Categories