« Previous entry | Next entry » Browse > Snippets

Skip to comments (18) PHP FTP Copy directory and sub directory
Posted by asamir on Jun 11 2008 @ 11:37  :: 1681 unique visits

[coe=php]php


////////////////////////////////////////////////////////
// Copy directory to directory with all sub-directory and files using FTP
// By:
// Ahmed Samir
// asamir@asamir.net
// www.asamir.net
//
////////////////////////////////////////////////////////



function ftp_copyAll($conn_id, $src_dir, $dst_dir) {
if(is_dir($dst_dir)){
return "
Dir $dst_dir Already exists
";
}else{
$d = dir($src_dir);
ftp_mkdir($conn_id, $dst_dir); echo "creat dir $dst_dir
";
while($file = $d->read()) { // do this for each file in the directory
if ($file != "." && $file != "..") { // to prevent an infinite loop
if (is_dir($src_dir."/".$file)) { // do the following if it is a directory
ftp_copyAll($conn_id, $src_dir."/".$file, $dst_dir."/".$file); // recursive part
} else {
$upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); // put the files
echo "creat files::: ".$dst_dir."/".$file ."
";
}
}
ob_flush() ;
sleep(1);
}
$d->close();
}
return "

All Copied ok ";
} // end fn function ftp_copyAll

// connect to FTP server
$ftp_user_name = 'FTP_User_name';
$ftp_user_pass = 'FTP_Password';
$ftp_server = 'FTP_Server';


$conn_id = @ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// login into FTP server
if (@ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
//echo "Connected as $ftp_user_name@$ftp_server\n";
ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 1000); // Set the network timeout to 10 seconds

$copy_result = ftp_copyAll($conn_id, 'Folder', 'FolderCopy');

echo $copy_result;

}else{
echo "Couldn't connect as $ftp_user\n";
}

@ftp_close($conn_id); // colse of ftp_connect
// @ftp_quit($conn_id);


[/code]

18 comments posted so far
Add your own »

1. On Jan 10 2009 @ 09:11 battery wrote:

http://www.batteryfast.com/
http://www.batteryfast.co.uk/

2. On Mar 15 2009 @ 16:05 guest wrote:

Our wholesale replica handbags  is one of the best Replica Purses  wholesaler.we are selling  Louis vuitton replica ,Chanel Replica ,Gucci Replica ,The handbags are Hermes Birkin ,Hermes Kelly ,Chanel 2.55 bag ,Louis vuitton replica Speedy 30 ,Louis vuitton Damier Canvas ,and we selling high and top Chanel wallet ,Louis Vuitton wallet ,Hermes belt . Choosing Replica handbags  to perfect your lifestyle: Business Opportunities.

Jadeshow’s replica Tiffany Jewelry  and Replica Bvlgari Jewelery  looks just like the real thing. Why pay more for a single piece of Tiffany Replica  jewelry,Bvlgari Replica Jewelry  when you can treat yourself to a number of replica pieces for the same price or less? Be simply spectacular with contemporary Tiffany-inspired jewelry!Jadwshow delights in the opportunity to offer our customers fine Tiffany Bracelets , Tiffany Necklaces , Tiffany Earrings , Tiffany Rings , Tiffany Bangles ,Gucci jewelry replica , Chanel wallet  and Louis Vuitton wallet
all at remarkably low prices.

We are top designer wholesale Replica handbags ,Louis vuitton replica  ,replica jewelry ,Bvlgari Replica ,Gucci Replica jewelry ,Swarovski Crystal , We offer a wide variety of high quality Tiffany inspired jewelry at very low prices. Gucci Necklaces ,Gucci Bracelets , Gucci rings , Gucci Earrings , Links Jewelry ,Chanel Rings  and Tiffany replica , Cartier Jewelry   more. Free shipping with any purchase over 5 items.Replica Louis Vuitton chanel replica handbag



We are the best and top Replica handbag  ,replica bags ,Replica watches  wholesaler in china,Our products is Replica louis vuitton handbags ,Chanel replica handbags ,Gucci replica handbags ,Miu Miu handbag  and we are selling Replica wallet ,best Louis Vuitton wallet ,Chanel wallet  replica,and sell Rolex replica watches ,Omega replica watches .Hermes replica bag

3. On Apr 15 2009 @ 09:16 guest wrote:

There is need to know about PHP FTP copy directory and sub directory so I found great information on your article. I want to learn more from Ahmed Samir but at this time I am on vacations I know about denver cheap flights because I know about all information car rental to go anywhere. I appreciate your article very much. Thanks Ahmed Samir

4. On Apr 15 2009 @ 09:45 Valencia wrote:

Wow great post, I came across your website after my VCP-310 Exam and found your website superb one for programming purpose. You have beautifully written and explained the PHP code. Great work done. I do like to write down further but I have to start training for 640-802 Exam that is going to be held next month. Then I have also another plan. I will for 350-001 Exam. Though I will remain quite busy but I will try to come across your website soon.

5. On May 05 2009 @ 19:03 guest wrote:

sohbet sohbet sohbet radyo okey oyna chat sohbet mirc yükle

6. On May 08 2009 @ 07:50 acotas wrote:

Well, Wednesday is the day for some paying back their credit. And some also are planning how to repair their credit, too. College Essay Some are checking out for mortgage loan modification that also help free up a little more funds to help to repair your credit. Wednesday for me is a day that triggers my mind facing challenging days yet pretty much meaningful.
Arts Essay | Expository Essay

7. On May 08 2009 @ 07:51 acotas wrote:

I have a nice quiet workspace at home and it is way less stressful than when i'm at work. I don't have all the nonsense that happens in the office at work. I love working at home.
Persuasive Essay | Essay Service

8. On May 11 2009 @ 11:44 guest wrote:

QIXINYAN


Way to teach a dog infected with love and enjoyment of the people around them is dog training. Not all the people who keep the dog know how to train a puppy, but who often find it impossible to carry out dog obedience training , people who have a different feel that they do so. Although some people will tend to the field of veterinary medicine, other people will choose more specific career dog. Perhaps the most popular dog-centric professional area is that dog training.
Police dog training is a great way for those who love the dogs, to help them use and dissemination of information. One important thing to remember is that the dog trainer can not only teach dog tricks and working dogs and their masters. In fact, owners tend to play a bigger roll than the dogs training process.
Some people choose to learn some dog training tips from an experienced coach or a veterinary surgeon of similar projects in the apprenticeship. This is often useful, because many of these puppies training experience in the field and constant practice. Customers will often choose a coach approved no more than one certification. Other routes may be the next dog learning how to train a puppy through the animal science program behavior.

Do you know how to lose weight? No matter how you do, do not skip breakfast. People who began the day a good healthy breakfast does not have loss weight diet throughout the day than those who do not eat breakfast. Or, if you prefer to drink your breakfast to reach weight loss, fruit juice is a good choice. All you need to do is the integration and go! Super simple!
In addition, how to lose pounds? Plan your meals so you eat every 3-4 hours, about 5-6 times a day. Do you want to ensure that your last meal is 3-4 hours, and then go to bed. It seems to eat more frequently in the first strange, but studies ways to lose weight by the books and internet, you’ll not only lose pounds success, but also have the energy level of the day.

Are you annoying with belly fat? I am sure you hear that sit-ups are one of the best belly fat exercises. How to lose belly fat? There are not only belly fat exercises, but have belly fat diet. Although it is entirely correct sit-ups will strengthen the abdominal muscles and make you more powerful in this regard, you may get rid of belly fat because you’re fat to improve the muscle to hold better, which in fact did not lose belly fat itself.
The key to lose belly fat is actually quite simple. Therefore, these two key points, first of all to take action to belly fat exercises, second, have belly fat diet every day. Do these, you will lose belly fat!

As a child, you can find kids jobs to get money. If not, maybe you are considering how to make children work in additional funds. jobs for 15 year olds are so many. However, we know that you will not find a real job; you just need a working pocket money. Finding jobs for 16 year olds is not a difficult task.

To make money online, first you need to make necessary preparations. In any field or industry you need in all walks of life through appropriate channels to meet their own, in order to succeed. Can you imagine how to starting your own business? It would be a good way to Make Money on the Internet and move forward at full speed is going to just be disastrous.
In the network marketing, you can set up shop online, start flower shop, or you can start carpet cleaning business.In my opinion, there are also other popular ways to make money,for instance, So starting a laundromat business at home, another way is to manage furniture making business at home.

10. On Jun 03 2009 @ 01:04 guest wrote:

Great post. My wife was well on my way to losing weight before she became pregnant<br/>, now she is gaining weight like crazy and battling smelly gas<br/>.  This happens to many people whether you are bbw women or a regular sized woman.  After the baby is born she will go back to working out five days a week.  Hopeful I won't have to find a minimum wage job.  If you are 14 years old you can also start working for minimum wage, but hopefully it would be a lot more. If you are a 13 year old girl or boy you will have to work off the books.

Are you morbidly obese?  Have you ever considered weight loss surgery.  Some people believe that it is the best way to lose weight, while others are totally against it.  It really depends on what you are willing to do before and after surgery.  It is not a magic weight loss pill that will do all of the work for you.  But if you try, there are many ways that you can lose weight and keep it off.

If you live abroad you can find apartments for rent in the UK or abroad. Where can I find summer jobs for teens?  You can check online or your local paper.  People are looking to rent their homes, sublet their expensive apartments, and even take on roommates to help save some money right now.  It is definitely a buyer's market.

11. On Jun 04 2009 @ 03:41 guest wrote:

This allows your body to build your exercises to lose fat lose love handles get rid of love handles diet to lose belly fat belly fat diet get six pack abs foods that burn fatmuscles back up and strengthen them so that they'll be better prepared for your next "hard" day at the gym. Exercises to burn belly fat You also want to make sure to eat as healthy a diet as you possibly can.Losing belly fat If you are breastfeeding, you will be burning plenty of calories, so you don't have to worry about counting anything, flat stomach foods and kinds of crunches also losing belly fat but make sure that the calories you do take in are from healthy foods. Exercises to lose belly fat You need to make sure to eat a balanced diet--preferably one that you work out with your doctor and is beneficial to both you and your baby. Remember, when you breastfeed, whatever you eat, your baby eats! reverse crunches On top of burning calories you should concentrate on toning your muscles, but know that you need to tone your entire body. If you focus on just your abdominal muscles, you could end up causing your belly fat to become more flat stomach foods pronounced instead of shrinking. This is because your belly fat sits on top of your abdominal muscles. When you over train a muscle group that muscle group grows in size and becomes more pronounced, causing the fat layer to extend outward as well. kinds of crunches for losing belly fatMake sure that the food you eat can be processed entirely by your body. When you eat refined foods and foods that are high fat burning foods Stand up straight. The distance between your feet should be equidistant to the width of your hips. negative calorie foods lose stomach fat foods for flat stomachSqueeze your abdominal muscles so that your navel pulls in toward your spine and contract your abs. flat stomach foods bad foods belly The goal is to create a ninety degree angle with your knees, but if you aren't able to lower yourself that farbad belly foods foods to avoid in fatty content the body stores the elements it cannot use or get rid of as fat. Work with your doctor to develop a menu that you can follow easily. Make as much of your food as you can and use natural ingredients as much as possible. Stay away from packaged and processed foods because there are elements of these that your body simply cannot deal with. BMI calculator tips to lose belly fat ab crunches The lunge is also a great exercise for shaping your backside!belly fat exercises The goal is go get your pelvis into a straight line with your right knee.

15. On Jul 11 2009 @ 04:29 sunzheng wrote:

cheap wow power leveling
buy wow gold
my wow power leveling
cheapest wow gold
CHEAP wow power leveling
BUY wow gold
MY rs gold
good wow power leveling
CHEAPEST lotro gold
cheap aion gold
buy wow gold
my wow gold
cheapest wow gold

16. On Jul 14 2009 @ 03:53 guest wrote:

buy wow gold
my wow power leveling
buy wow gold
good wow power leveling
BUY wow gold
my wow power leveling
CHEAP rs gold
cheap wow power leveling
CHEAPEST lotro gold
MY aion gold
buy wow gold
cheap wow gold
CHEAPEST wow gold

18. On Jan 05 2010 @ 14:56 uggbaileybutton wrote:

bailey button uggs

-ugg boots cheap

ugg boots uk

ugg classic

Add a new comment

Name:
Password: (leave empty for anonymous comment)
 
View formatting tags Comment: