1

Can anybody tell me why this function isn't copying the file at all?

$pluginfile = get_bloginfo('template_url') . '/wp-content/plugins/supersqueeze/supersqueeze.php';

$urlparts = get_bloginfo('template_url');
$homeurl = home_url();
$urlstrip = str_replace($homeurl, '..', $urlparts);
$urldest = $urlstrip . '/supersqueeze.php';

function copyemz(){ 
global $pluginfile; global $urldest;
if(!@copy($pluginfile,$urldest)) {
        $errors= error_get_last();

    }
}

This file is run from /public_html/wp-admin/plugins.php

I need it to copy the file at ($pluginfile) /public_html/wp-content/plugins/supersqueeze/supersqueeze.php

to ($urldest) /public_html/wp-content/themes/[active wordpress theme] - of course replacing [active wordpress theme] with the directory of the theme.

8
  • 4
    Remove @ and tell us what error you get Commented Jan 11, 2011 at 6:25
  • 3
    This is one of the places where you don't want to use the error suppression @ operator. Unless you have a pro hoster with suexec/fastcgi-php, then it's probably a permission problem. Commented Jan 11, 2011 at 6:25
  • 1
    Why did you put "@" before copy? Remove it and you'll get exact error, not guesses. Commented Jan 11, 2011 at 6:26
  • Warning: copy(localhost/wordpress/wp-content/themes/striking/supersqueeze.php) [function.copy]: failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\test.php on line 4 Array Commented Jan 11, 2011 at 6:29
  • @Jared: ta-dah. Is not it enough to solve your problem? Commented Jan 11, 2011 at 6:31

2 Answers 2

1

You need to ensure that you have write permissions to /public_html/wp-content/themes/[active wordpress theme] as well as any other files you may be overwriting.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow come to think of it, I thought I edited the permissions but apparently I didn't. Thanks for reminding me! Lol.
1

So, the second parameter to copy() must be a local file. Make sure it is also a writable destination (chmod) like webbiedave said.

$desturl = "./supersqueeze.php";

The reason is two-fold. PHPs http stream wrappers don't support POSTing or PUTing files, which a write-to action would require. Second, your webserver probably wouldn't support HTTP PUT either. (Though a small requesthandler script could handle such.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.