Jump to content

Can't copy files per PHP in processwire directories.


Recommended Posts

Posted

Hello,

I'm building a module which needs to copy a template file from its module directory to /templates/default/.

I'm using copy(source, dest) and I don't even get an error message with active debugging. Just nothing happens.

I assume there is some kind of permission problem, but I don't know where to start with that, since I'm not very familiar with Linux (the server runs apache2 on it).

Thank you for any help!

This is what I'm using for tests the ___install() function of the module:

$path = wire(config)->paths->siteModules.'fma-helper/';
copy($path.'_head_metadata.php', $path.'testtesttest.php')
Posted

I'd suggest using wireCopy(), but you should also make sure, that php does have sufficient access rights to the sourcefile as well as the destination folder.

Edit: Sry, thought this would also be for single files, but it seems it's only for copying whole directories.

  • Like 1
Posted

If you can install processwire correctly it's probably not an permission issue, but no you cannot add missing permissions to the user running apache and php.

Posted
$path = wire(config)->paths->siteModules.'fma-helper/';
copy($path.'_head_metadata.php', $path.'testtesttest.php')

Shouldn't this be wire('config') - with quotes around the config?

Also, echo out $path to make sure it is what you expect.

Posted

It worked without quotes as well, bit gives a notice when you turn on Debugging. The path is also correct. Looks like I just have to ask the user to copy the file. :(

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...