Reputation: 2170
I am trying to move a file 'avatars/generic.jpg'
to a folder that has a dynamic variable in it - $_SESSION['user_id']
- the path would look like this
avatars/$_SESSION['user_id']/generic.jpg
but I can't get it to work using the copy function in PHP. I have tried curly braces etc around the session variable without success....
Any suggestions?
Upvotes: 0
Views: 47
Reputation: 1146
kindly use . as to concatinate the variables
"...avatars/".$_SESSION['user_id']."/generic.jpg ";
Upvotes: 1
Reputation: 936
Try:
<?php
copy("avatars/generic.jpg", "avatars/" . $_SESSION['user_id'] . "/generic.jpg");
?>
By using the '.' operator for concatenation you don't have to worry about escaping.
Upvotes: 1