change wordpress image upload to another directory in public_html - php

I want to set my wordpress files to upload to /home/public_html/images instead of /wp_content/uploads, I have gotten to the point that it gives me the correct url for /home/public_html/images but I have to move the new files from /wp_content/uploads to /home/public_html/images for it to work
I have tried changing the upload path in wp-options.php but that just makes a subdirectory in my sites folder called public_html and puts the image there instead of actually putting it in /home/public_html/images

Try going to the wp_config.php file and adding this line of code:
define('UPLOADS', 'images');
This should put the images in a folder under /public_html instead of the typical /wp_content folder.
https://developer.wordpress.org/apis/wp-config-php/#moving-uploads-folder

Related

How to chnage the uploads directory path in wordpress

I have used
define( 'UPLOADS', 'wp-content/'.'files' );
but it is only chnage the path witin wordpress folder.
I need to setup My uploads folder outsite the my C drive. I have setup the server configuration but unable to set the path in wordpress
my current path uploads directory is
C:/xampp/wordpress/wp-content/uploads
but the path is needed that
D:/images/uploads
Change Default Media Folder
Open your wp-config.php file, locoed at the root of your WordPress installation, and add the following snippet:
define('UPLOADS', 'wp-content/myimages')
Make sure you add this code before the line:
require_once(ABSPATH.’wp-settings.php’);
If the directory doesn’t already exist, WordPress will automatically create it as long as the wp-content folder is writeable. Otherwise you can great the folder yourself via FTP, cPanel etc.
You can also change the way uploads are organized. If you open your uploads folder you’ll notice that files, by default, are sorted into years. You can change your file organization so that all media files are dumped in the one folder. Go to Settings > Media and uncheck “Organize my uploads into month- and year-based folders.”
Not only will it make your URLs simpler, it will also make it easier to see all your files in one place instead of having to sort through month and year directories.

Move file from temporary folder to uploads folder

In my WordPress the visitors can upload files like texts and this files go in this path
C:\xampp\htdocs\www\wordpress\wp-content\uploads\temporary, After validating I need to insert this files in this path C:\xampp\htdocs\www\wordpress\wp-content\uploads\2014\10 like attachment , Should I using wp_insert_attachment or wp_handle_upload() ?
I don't know if this is related to wordpress because I do not have a slightest idea about it. But in php, you use the copy() function to copy a file from one folder to another. And if you want to remove the file from the temporary folder, you are looking for the unlink() function for deleting a file

Uploading a file with PHP and moving it

I have a form where users can upload images. I know how to do it with HTML/PHP and I know that I have to move the temp file to the permanent directory. Well this all works well when my file that processes the form, is in the root directory. But, I would like to have it work within another directory, on the same server.
The Structure is this:
ROOT
>images
>mobile
>upload.php
I would like to have the file put inside images, which is outside of the "mobile" directory.
My current upload path that does not work is:
define('UPLOADPATH', 'images/');
So essentially I need to go back one directory and then into images. How can I do this?
You need to add a .. To move to the parent directory. See this resource for more information

upload file outside of root folder

public_html/(root)index.php
/image/123.jpg
/subdomain(root)/upload.php
I have file upload.php can upload image, this file is locate in sub-domain folder (I have set sub-domain folder as another root)
I need to upload image to main domain, /image/ (image's folder)
however I could not find the right path. I have try ../ but it wont work above the root
anyone know how to solve this problem?
Use path like /home/content/html/images

Is my temp folder discoverable after image upload form?

I have a simple php image upload form that saves the images in a temporary folder, lets call it temp, and when the image is approved by me I manually copy it to the album folder.
My question is, if there is a way for someone or I don't know, a search engine maybe to find "guess" my temp folder and what images are inside ( before approve ).
You wrote it yourself:
The temp is inside public_html
Doesn't that answer your question?
If this is not desirable, create a .htaccess file inside the temp folder, with this content:
Deny from all
It depends on the location of the temp folder. If the folder lies outside the root directory of your server its not discoverable but if it lies inside the root directory it is discoverable. However you can limit the access to your temp folder if its inside the root of the server through htaccess. Or you can place a index.php file inside the folder with a header redirect so that no one can see the file(image) list.

Categories