I am compressing directories and sub directories using PHP zip library. Everything is working fine except renaming files under sub directories. This code is renaming the files successfully in root directory
$zip->addFromString(basename($file), $download_file);
$zip->renameName(basename($file), 'nicename.mp3');
but it is not renaming files in sub directory. Can anybody assist please ?
I have taken this code from Here
Related
i use ftp_get to download my ftp files from my server to my laptop. and i want to download just somes dirs and files but under the parent name
for example i have a folder public_html contains 3 folder A and B and C. i want to get just the A Folder but also the parent which is public_html im looking for this result : public_html/A. i mean i want to download the parent/child
this is my code :
ftp_get($conn_id, "public_html/A", "public_html/A", FTP_BINARY);
i get only the sub folder A
I am having issues transferring an uploaded file with the class_upload library from the directory of the .php file to a sibling of the parent directory.
Here is the directory breakdown
home/hosted_domain/public_html/en_shop/profile.php <--- this is where the php file that handles the upload is
home/hosted_domain/public_html/shop/avatars/ <--- this is where the uploaded file needs to get
this is what I have tried -
move_uploaded_file($_FILES['user-avatar']['tmp_name'], "home/hosted_domain/public_html/zadomaigradinata.bg/avatars/$avatar");
I've also tried using the site's URL + the directory /avatars/ but that didnt work either.
So how should we move the uploaded file ?
Prepend the directory path with a /. This tells the system that you want that explicit path. Without it, move_uploaded_file is trying to move the file to /home/hosted_domain/public_html/en_shop/home/hosted_domain/public_html/zadomaigradinata.bg/avatars/$avatar which is not what you want.
I'm trying to find the best method of selecting .exe files within a directory, ignoring files inside other directories.
So far, I have the following:
$files = scandir('/path/to/dir');
Now, how can I remove "..", "." and other directories and files within that directory that are not .exe files?
Thanks.
$files = glob('path/to/dir/*.exe');
Thanks #chris85
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 ./');
I need to zip non-empty folder with all files and sub-folders. I found lots of classes and functions, but all of them zip whole directory structure or something like that. But I need to zip only the content of given folder.
In advance thanks for answers