Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/73517-solved-copy-outside-script-directory/
Share on other sites

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

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

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.