Jump to content

[SOLVED] copy() outside script directory


severndigital

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
Share on other sites

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

 

 

 

Link to comment
Share on other sites

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.