EOSERV Forum > Lounge > PHP copy() Trouble
Topic is locked.
Page: << 1 >>
PHP copy() Trouble
Author Message
Post #81469 PHP copy() Trouble

Im trying to make a Admin Panel for a site that im making and im doing the sub-domain/account creation and im trying to copy the default index.php into the folder.

$newdirect = "/Users/$domain";

mkdir($newdirect);

copy("/Default/index.php", "$newdirect");

copy("/Default/Logo2.png", "$newdirect");


NONE of thoose work. No errors, they just dont work. Not even the mkdir(). Anyone got some suggestions?

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81472 Re: PHP copy() Trouble

Doubt it'll fix it, but still a pretty dumb thing to do.

Why do you have "$variable". The variable is already a string so you can just do $variable with no quotes. Once again, probably won't fix your error.

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81473 Re: PHP copy() Trouble

I no, its just a habit. 

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81474 Re: PHP copy() Trouble

Make sure the permissions are okay. If the file doesn't have permission to make a new directory, it can't.

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81475 Re: PHP copy() Trouble

Yeah, i tried that before i posted. Still didnt work.

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81476 Re: PHP copy() Trouble

Well a simple way to check what is failing(pretty sure it's mkdir but it doesn't hurt to check) is to check the return value. copy & mkdir return true on success and false on failure.

I'm going to take a wild guess and say that the directory name you want to create isn't valid.
http://www.php.net/manual/en/function.mkdir.php
Look at the first comment made. I would use what he did and try to see if that works.

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81477 Re: PHP copy() Trouble

Yeah, read something earlier. Im pretty sure it returns 1 for true and 0 for false?

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81478 Re: PHP copy() Trouble

Yeah, check what mkdir returns and see if it's the problem or not.

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81479 Re: PHP copy() Trouble

Its not returning anything?

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81480 Re: PHP copy() Trouble

if (mkdir($newdirect) == true)

{

    echo 'success';

}

else echo 'failure';

Simple as that.

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81482 Re: PHP copy() Trouble [SOLVED]

Oh, duh. Inewtat lol.

Yup, thats the error. Thx! Now i gotta fix it.

Fixed, im stupid. Wasnt using ftp directory -.-

 I feel very retarded lol. 

/home/www/wildsurvival/admin/Users


---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Post #81483 Re: PHP copy() Trouble

Alright, just did a little test, I think I have your problem.


$newdirect = "/Users/$domain";

That is wrong.


$newdirect = "./Users/$domain";

That is right.


./ is taking your current directory and then going into users and then $domain(whatever the variable value is)


/ I have no clue what it does, but it's not right :P

---
http://www.addipop.com
14 years, 3 weeks ago
Post #81484 Re: PHP copy() Trouble [SOLVED AGAIN]

i tried ./Users and it wasnt working. But the ftp directory worked.

Edit: Ok now when i try to move the defaults and stuff into it. It turns into an application/octet-stream .

Edit: Fixed

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 3 weeks ago
Page: << 1 >>
Topic is locked.
EOSERV Forum > Lounge > PHP copy() Trouble