Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
php copy Not Working adder
Hi, I'm stuck with a short bit of code:
copy($pngoldpth, $pngnewpth) or die("Unable to copy PNG.");
delete("$pngoldpth"); echo "PNG moved successfully"; The script dies even before it has a chance to get to the "die" bit :) I never get any output. Enabled all error messages - not a single warning or error message, just a blank screen. I thought the folders had suddenly become not writable. Unlikely because my file upload script is working. Just in case tried this line:
echo ( is_writable($pngnewpth) ) ? 'writable' : 'not writable';
Also tried echoing the variables and I get the expected output from them. Is there something obvious that I'm missing? Please help.
Look carefully at the value for the paths. Is it the full server path? adder
@g1smd, thank you, it was a very good point. No, I was actually using a relative path (also tried the actual www url) how silly :) I now changed the variables to the full path (i.e. /servername/local/home/myname/mydomain.com/mydir/) and it copied the file ok. But wait, I'm celebrating too early. The delete function is now not working. The error message is: Fatal error: Call to undefined function delete() in /servername/local/home/myname/mydomain.com/mydir/test.php on line 13 Any ideas why?
oh, I actually replaced delete("$pngoldpth"); with unlink("$pngoldpth"); and it works fine. However, I'm still curious about the "delete" function! Is it not supported any more? rocknbil
Was there ever one [ php.net]?
This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place. You might find it more useful to use the DOCUMENT_ROOT environment variable where appropriate, making your app more portable: $pngoldpth = $_SERVER['DOCUMENT_ROOT'] . "/mydir";