58.gif

Search (advanced search)
Use this Search form before posting, asking or make a new thread.
Tips: Use Quotation mark to search words (eg. "How To Make Money Online")

07-13-2016, 03:28 AM
Post: #1
[How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
Hello BBHFellows,

I Came up with a disaster and need to zip whole directory of a server inside it.

Searching up and down, left and right to get a working php code on zipping files and folders inside a ftp server (as a backup or transferring for the website). i put over 25 hours in 3 days for searching and i found nothing to work for me.


In need of a working php script with the following features:

1-) Ability to ZIP and SAVE (.zip extension) the whole directory including all of the sub-files and sub-folders inside the FTP server.
2-) Zip large size directories (+128 MegaByte files zipping, if it is possible)
3-) the php script must work with: PHP version 5.2 (i have to use this version)
4-) I have a unzipping php script that works fine for files about 50 mb, but if it is possible i need this asked above script contain the unzipping feature for large files (or at least different script for this purpose), too.

5-) Also need a working php script for remote upload (upload any type of files from web/url) to upload and save any type of files to the ftp server REMOTELY.

so if everyone can help, don't hesitate to aid, you gonna save me a lot of headache and time and i will APPRECIATE that forehandly.

As Always Maximum Respect my Friends.
As Always Maximum Respect BBHFriends Cool

07-16-2016, 07:18 PM
Post: #2
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
This should work for your first 4 requirements. I've been using it for a while now.

It will automatically zip the root of whichever directory its in, so just put it in the same directory you want zipped, and you should be good to fo..
https://gist.github.com/jonmaim/1141513

As for #5, here's a super simple PHP snippet you can throw into a php file. Allows for ftp-ftp transfer remotely (fast as hell!)

Code:
$connection = ftp_connect($server);

$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);

if (!$connection || !$login) { die('Connection attempt failed!'); }

$upload = ftp_put($connection, $dest, $source, $mode);

if (!$upload) { echo 'FTP upload failed!'; }

ftp_close($connection);

If you need some help, respond here then PM me, will get back to you asap.
07-20-2016, 05:04 AM
Post: #3
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
First of All thank you jethroucc for your response.

Secondly:

I tried it.download the script and unpacked it and upload the actual php. this php script makes several small zip of all files, so i won't get ONE Zip file instead it would be several depends on the directory size (split the zip files to cap of 4mb).
it will need to create a folder called temporary where the .zip files will be saved inside the same directory of the actual .php file.
i made the folder and my files and directory was to big, so it needs to create multiple zip files inside the folder "temporary" !

BUT

I got just one file of 4mb and the rest of the files didn't created. i think the script has a problem.

what i am doing wrong?
As Always Maximum Respect BBHFriends Cool

07-22-2016, 12:37 AM
Post: #4
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
Hey its quite straightforward actually.

personally i prefer to tar directly from console using tar/gzip, but from php (and granted u have exec and correct permissions on file containing this code) u could use:-

PHP Code:
<?php
      exec
("tar czf archive.gz /path-to-compress");
?>

Will include all subfolders within that path, can add path before archive.gz if you wish to save elsewhere

To zip recursively with subfolders, you need to create array of all files, then create zip object add each file (foreach)

exact code (messy) here:- http://stackoverflow.com/questions/49147...-using-php

PS can find answeres to almost all of lifes problems on stack exchange :)
07-22-2016, 02:16 AM
Post: #5
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
Thanks Loomy for taking time and investigating others problems, really appreciate that,
but
my friend, i cannot use exec() code be cause my hosting (idiot) is disabled that for security problems.
but i try and tweak the source code to see if is any way to get arount with that or...

As Always Maximum Respect my Friends.
26.gif
As Always Maximum Respect BBHFriends Cool

07-22-2016, 11:45 PM
Post: #6
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside...
(07-22-2016 02:16 AM)M@xIMuMRespect4BbhF Wrote:  Thanks Loomy for taking time and investigating others problems, really appreciate that,
but
my friend, i cannot use exec() code be cause my hosting (idiot) is disabled that for security problems.
but i try and tweak the source code to see if is any way to get arount with that or...

As Always Maximum Respect my Friends.

could try upload a shell to your own hosting, or similar, but will get u in less trouble:_ https://sourceforge.net/projects/phpfileman-0-1/
07-23-2016, 09:44 AM
Post: #7
RE: [How to] zip a whole directory and it's subfiles and subfolders using php inside FTP server ??
Thank you again Loomy :)

i was wondering there must be such file management script on php, but i was exhausted with trying the old fashion way (just one script for one reason, it's smaller).

now i try it too see if it has the all features that i need.
it has the compression feature lucky i am :)

As Always Maximum Respect my Friends.
As Always Maximum Respect BBHFriends Cool





79.gif