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
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Sat Sep 05, 2009 8:43 pm
Hey guys I just want to copy and paste a picture but my function is not working, the page just executes without doing anything. no error messages or anything. Any ideas would really help me. Thanks.
Code: Select all
$src='../../images';
$dest='../../usercontent/$username/images';
$fsrc = fopen($src,'r');
$fdest = fopen($dest,'w+');
$file = '../../images/defaulticon.png';
$newfile = '../../usercontent/$username/images/defaulticon.png';
copy($file, $newfile);
fclose($fsrc);
fclose($fdest);
header("Location: ".$session->referrer);
Last edited by
scarface222 on Sun Sep 06, 2009 12:17 pm, edited 1 time in total.
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Sat Sep 05, 2009 9:03 pm
Thanks for the response but still no luck man. I changed it and all the code right up to and after the copy fucntion executes.
Code: Select all
$_SESSION['reguname'] = $_POST['user'];
$username=$_POST['user'];
$_SESSION['regsuccess'] = true;
mkdir("../usercontent/$username",0777);
mkdir("../usercontent/$username/images",0777);
//copy default pic
$file = '../../images/defaulticon.png';
$newfile = "../../usercontent/$username/images/defaulticon.png";
copy($file, $newfile);
header("Location: ".$session->referrer);
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Sun Sep 06, 2009 4:32 am
Are you sure that your paths are right:
Code: Select all
mkdir("../usercontent/$username/images",0777);
and
Code: Select all
$newfile = "../../usercontent/$username/images/defaulticon.png";
don't seem correct to me: too many ../
You're creating a new directory, but trying to copy the file to a location that's nowhere near that new directory.
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Sun Sep 06, 2009 11:06 am
LOL thanks man you got some good eyes and that was a dumb mistake. You were exactly right. Appreciate the comments.