php-n00b Posted January 5, 2010 Share Posted January 5, 2010 What's Up? OK, so I've been trying to copy a file to the root of my webserver from a folder, But when you use this code. <?php chdir('saved/'); $file = 'Archive.tar.gz'; $newfile = (New.tar.gz); if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> It copies it to the same dir, I've tried $newfile = (/public_html/New.tar.gz); But that doesn't work, If the folder was in the same folder as where you where currently chdir'd to, then it would be $newfile = (folder/New.tar.gz); But how would you copy it to the root of your server? Anyone Know? Thanks Bye. Quote Link to comment https://forums.phpfreaks.com/topic/187314-copying-to-above-folder/ Share on other sites More sharing options...
MadTechie Posted January 5, 2010 Share Posted January 5, 2010 <?php $file = 'saved/Archive.tar.gz'; $newfile = '/New.tar.gz'; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/187314-copying-to-above-folder/#findComment-989180 Share on other sites More sharing options...
teamatomic Posted January 5, 2010 Share Posted January 5, 2010 <?php //chdir('saved/'); $file = '/path/to/Archive.tar.gz'; $newfile = 'path/to/New.tar.gz); if (!copy("$file", "$newfile")) { echo "failed to copy $file to $newfile\n"; } ?> HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/187314-copying-to-above-folder/#findComment-989182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.