I have access to a wordpress theme folder directory via FTP. I want a particular folder to be ziped inside the theme folder so i can download it. What code i use?
/wp-content/themes/ - my directory to access
My theme folder name is 'vintage'
I want upload and run a php code inside /wp-content/themes/ so it makde a zip file or the folder 'vintage' located at /wp-content/themes/ can any one help me with this?
It could be something like:
system('cd /path/to/htdocs/wp-content/themes/; zip -r vintage.zip ./');
Related
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
I am trying to define the wordpress upload folder outside the installation directory. My directory structure is:
/path/to/my/base/folder
|-> wordpress (the wordpress installation)
|-> uploads (the required upload folder)
I have tried defining the 'UPLOADS' in my wp-config.php like:
define('UPLOADS', '../uploads');
Wordpress creates the folder and the images are uploaded there, but cannot use it when required. The image URL looks like :
www.myhost.dev/../uploads/image-file-name-format.jpg
But if I use absolute path to define the 'UPLOADS' like
define('UPLOADS', '/path/to/my/base/folder/uploads');
this works.
But the problem is, then the image url looks something like:
www.myhost.dev//path/to/my/base/folder/uploads/image-file-name-format.jpg
This tells the location of the file and this can be a security issue.
So, is there a better way to define the relative path for the uploads folder which will point to my required folder?
Thanks in advance.
I have done it at last by making a symlink with proper permissions. In my case, when I tried to make a symlink, the symlink did not have enough permission to write into the folder. This was because of my system (I am using Macbook). So what I did is:
$ cd wp-content
$ mv uploads /path/to/my/base/folder/
$ ln -s ../../uploads uploads
$ chmod -h 777 uploads
Check the last line where I have changed the permission for the symlink. Normally in most of the cases, you don't need to change the permission of the symlink, as they inherit the permission of the folder.
A couple of notes that may help people:
define( 'UPLOADS' , 'blah') is typically RELATIVE to the WordPress core root directory. The default is 'wp-content/uploads'. If you try to put the uploads outside of the WordPress directory with something like '../uploads/' as the define the upload URL will typically not work causing problems.
If you set the path with the define() inside your wp-config.php WordPress will NOT read the upload_path setting, if you have used it.
I found that setting the upload_path option in WordPress is better for storing media files outside the WordPress install path. Login to your WP Admin and go to the url /wp-admin/options.php to see the "raw" options list for WordPress.
Look for the upload_path setting. Put in your FULL PATH on the server like /usr/wpsite/uploads/ where /usr/wpsite/public_html would be where your WordPress core install typically ends up. Save the settings.
Your uploads will now be placed OUTSIDE the WordPress install directory. Make sure the web server has read/write permissions to the directory.
Also note that WordPress will put ALL FILES in that directory. It will not separate them into year/month subfolders as is the default for a typical WordPress install. If someone knows how to retain that feature please comment.
If you take a look at this link http://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-media-upload-location-in-wordpress-3-5/
You need to use a path like so
define( 'UPLOADS', ''.'uploads' );
is it necessary to unZip all sub-folders in Theme folder ?
actually when i download some theme its in Zip format and when i try to upload it it doesn't .
but when i open the zip file and find more sub-zip folders in theme folder .
for example plugins are in zip format in theme folder.
it sometimes installs and sometimes again fails .
so please help me whats the problem .
is it necessary to unzip each and every sub-folder or plugin in main Theme Zip ?
Yes Packaged themes come with multiple zip inside, you can extract that theme and if you have good knowledge of wordpress directory structure you can find theme folder only containing theme files like single.php, style.css etc and upload it to theme directory of wordpress and plugins to plugin directory.
Also you can refer to readme.txt come up with in zip which shows how to use and install theme.
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
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