severndigital Posted October 16, 2007 Share Posted October 16, 2007 I would like to work with files that are located outside of the directory my php script is in. when I use the copy() command the script doesn't seem to want to work. am I doing something wrong? or is there a different command I should be using? here is my code // File services $filename = "VCADexport.txt"; $filepath = "/home/fedex/fedex_output/"; //$templatename = "VCADexport.txt"; //$templatepath = "/home/fedex/fedex_empty_file/"; $backupname = "VCADexport-$timestamp.txt"; $backuppath = "/home/fedex/fedex_backup/"; //move the original file to the backup area $filestring = "$filepath$filename"; $backupstring = "$backuppath$backupname"; $makeCopy = copy($filestring,$backupstring); I am pretty sure my permissions are correct. I chmod 777 all the files and directories I needed to use. Any help would be great .. thanks, Chris Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/ Share on other sites More sharing options...
BlueSkyIS Posted October 16, 2007 Share Posted October 16, 2007 is $timestamp being populated? Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/#findComment-370893 Share on other sites More sharing options...
severndigital Posted October 16, 2007 Author Share Posted October 16, 2007 yes .. all information is being output correctly from the script .. i echoed each variable before I posted the script. my mistake I forgot to copy and paste that line of code. should be $timestamp = time(); thanks, chris Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/#findComment-370899 Share on other sites More sharing options...
simcoweb Posted October 16, 2007 Share Posted October 16, 2007 I don't see where you've actually 'executed' the command. You've basically populated a bunch of variables. Is there more code that actually summons the $makeCopy? Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/#findComment-370913 Share on other sites More sharing options...
mattal999 Posted October 16, 2007 Share Posted October 16, 2007 what do you get when you run the script on the screen? Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/#findComment-370918 Share on other sites More sharing options...
severndigital Posted October 16, 2007 Author Share Posted October 16, 2007 I got it working. It was a permissions problem on the backup directory. I also changed the copy() command to be included in an If statement something like this if(!copy($filename,$copyname){ echo 'the file was not copied'; } which helped me with error correction. thanks, chris Quote Link to comment https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/#findComment-370947 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.