Jump to content

Problem Copying File


stevesimo

Recommended Posts

Hi, I am having trouble with a relatively simple script.  There are 3 steps, 1) create a folder 2) chmod folder 3) copy file to new folder

 

Here is my code

 

  mkdir('newfolder',0777); //create folder
  chmod('newfolder', 0777); //chmod folder
  copy('file.php','/newfolder/file.php') or die('failed to copy file');

 

Can anyone see what I am doing wrong?

 

thanks, Steve

Link to comment
https://forums.phpfreaks.com/topic/122545-problem-copying-file/
Share on other sites

it may be your destination path. you might want to use the entire path or a relative path:

 

copy('file.php','/newfolder/file.php');

 

probably should be more like:

 

copy('file.php',$_SERVER['DOCUMENT_ROOT'].'/newfolder/file.php');
// OR
copy('file.php','newfolder/file.php');

 

 

Link to comment
https://forums.phpfreaks.com/topic/122545-problem-copying-file/#findComment-632714
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.