Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Subscribe and Support WebmasterWorld
php copy Not Working adder msg:4451527 8:49 pm on May 9, 2012 (gmt 0) 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.
g1smd msg:4451539 9:30 pm on May 9, 2012 (gmt 0)
Look carefully at the value for the paths. Is it the full server path? adder msg:4451822 1:58 pm on May 10, 2012 (gmt 0)
@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?
adder msg:4451835 2:25 pm on May 10, 2012 (gmt 0)
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 msg:4451886 4:12 pm on May 10, 2012 (gmt 0)
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";