title: Using PHP to move files between cPanel accounts on the same server
body: <p>We recently upgraded our server to cPanel 78 and migrated from EA3 to EA4. Our server only has two sites on it, and prior to the upgrade we could use PHP scripts to copy files between the two sites using PHP's file_exists() and copy() functions.</p>
  <p>We could use the file_exists() function to grab files from site1 and migrate them to site2 using code similar to this:</p>
  <pre><code>$current_path = '/home/site1/public_html/uploads';
  $new_path = '/home/site2/public_html/uploads';
  
  if(file_exists($current_path.'/v2n62l6v.jpg')) {
      echo 'File exists: true' . &quot;\n\n&quot;;
      copy($current_path.'/v2n62l6v.jpg', $new_path.'/2020/03/30/v2n62l6v.jpg');
  } else {
      echo 'File exists: false' . &quot;\n\n&quot;;
  }
  </code></pre>
  <p>This code also creates new directories and sets the permissions to 0755.</p>
  <p>After the upgrade, when we attempt to execute the script, we are greeted with this error:</p>
  <pre><code>File exists: true
  Warning: copy(/home/site2/public_html/uploads/2020/03/30/v2n62l6v.jpg): failed to open stream: Permission denied in /home/site2/public_html/move.php on line 15
  </code></pre>
  <p>We are able to move the files if we set the permissions to the folders to 0777, but I would prefer to not have to change all of the folder permissions (there are 10s of thousands).</p>
  <p>Any ideas on where to start or what settings may have changed during the upgrade to either EA or cPanel/WHM?</p>
  <p>Site is using:</p>
  <p>PHP 5.5 (ea-php55)
  DSO PHP Handler
  CENTOS 6.10
  cPanel v78.0.47</p>
  <p>I am happy to provide any other information to help trouble shoot this issue.</p>
  <p>Thanks so much for any/all help.</p>