PHP copy?

Avdelningen för webbrelaterad programmering och grafisk design.
Post Reply
User avatar
Spixx
Posts: 1613
Joined: 2004-03-20 16:47:34
Contact:

PHP copy?

Post by Spixx »

Okej snabb fråga varför vill inte denna kod:

Code: Select all

$file = '/user.php';
	        $newfile = '/users/$username/index.php';
	            
	            if(!copy($file, $newfile)) {
	                $feedback[] = 'Error: File creation failed';
	            }
Fungera? Felkod följer:

Code: Select all

Warning: copy(/user.php) [function.copy]: failed to open stream: No such file or directory in b-landia.net/httpdocs/temp/upload/inc/register.inc.php on line 41

jag har testat att köra på full http sträng på startfilen vilket funkar (men ngt jag eg inte vill göra) hur gör jag?

Edit: Jo just det user.php ligger i samma map som scriptet? men det körs under en regg där en mapp skapas med namnet från variabeln $username
User avatar
xerxes
Posts: 835
Joined: 2002-03-08 21:48:21
Location: Lund
Contact:

Post by xerxes »

Du måste ha "-tecknet istället för '-tecknet om du vill att variabler ska parsas:

Code: Select all

$newfile = "/users/$username/index.php";
There are 2 kinds of people in the world: Those who understand hexadecimal, and those who don't.
User avatar
Spixx
Posts: 1613
Joined: 2004-03-20 16:47:34
Contact:

Post by Spixx »

tack! :D för de som är intresserade :

Code: Select all

 $file = "./inc/user.php";
	        $newfile = "users/$username/index.php";
	            
	            if(!copy($file, $newfile)) {
	                $feedback[] = 'Error: File creation failed';
	            }
Post Reply