Page 1 of 1

[SOLVED] Copying Images from 1 directory to another...

Posted: Tue Feb 01, 2005 5:46 am
by Dale
erm... I have a problem with image moving.

I want my action to move a image from a users directory (eg; /users/Dale) to a temp directory (eg; /temp).

I use this:

Code: Select all

<?php
copy ("./users/".$theuser&#1111;'username']."/$file", "./temp/".$theuser&#1111;'username']."_$file") or die ("Could not delete");
?>
$theuser['username'] returns Dale.
$file returns php.gif.

But it always says Could Not Delete. WhY?

(All the user directories and TEMP folder is CHMODed 777)

Posted: Tue Feb 01, 2005 5:51 am
by JayBird
do you want to move or copy?

to move a file, use the rename function

http://uk.php.net/manual/en/function.rename.php

Mark

Posted: Tue Feb 01, 2005 5:55 am
by Dale
Bech100 wrote:do you want to move or copy?

to move a file, use the rename function

http://uk.php.net/manual/en/function.rename.php

Mark

ok, the example of there uses /home/user/login/docs/ so I take it I have to use the FULL PATH address? /public_html/blah/blah ?

Posted: Tue Feb 01, 2005 5:58 am
by JayBird
Yeah, i usually do

Code: Select all

$_SERVER&#1111;'DOCUMENT_ROOT']."/path/to/images/";

Posted: Tue Feb 01, 2005 6:06 am
by Dale
Bech100 wrote:Yeah, i usually do

Code: Select all

$_SERVER&#1111;'DOCUMENT_ROOT']."/path/to/images/";

I've done that and it seems more promising, however I have this error:
Warning: rename(/home/dframe/public_html/users/Dale/header.tpl,/home/dframe/public_html/temp/): Not a directory in /home/dframe/public_html/service.php on line 113
Could not delete
Heres how I have the code:

Code: Select all

<?php
rename ($_SERVER&#1111;'DOCUMENT_ROOT']."/users/$theusername/$thefile", $_SERVER&#1111;'DOCUMENT_ROOT']."/temp/$theusername_$file") or die ("Could not delete");
?>

Posted: Tue Feb 01, 2005 6:08 am
by Dale
Ahhh fixed :)