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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

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

Post 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)
Last edited by Dale on Tue Feb 01, 2005 6:09 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post 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 ?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Yeah, i usually do

Code: Select all

$_SERVER&#1111;'DOCUMENT_ROOT']."/path/to/images/";
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post 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");
?>
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Ahhh fixed :)
Post Reply