Jump to content

PHP Copy function


Don E

Recommended Posts

Hello everyone, Does the copy function only take literal strings for parameters, and not variables that are strings? is there a way to copy a file where the path and name are stored in a variable?http://php.net/manual/en/function.copy.php Thanks.

Link to comment
Share on other sites

I meant more along the lines of the following example. $origImg = "uploads/$this->pic_name";$copyImg = "uploads/$this->pic_name" . "orig";copy($origImg, $copyImg);When using the above without quotes I thought why the copy failed but doing the above with double quotes fails as well.

Link to comment
Share on other sites

Thanks for the input guys. Unfortunately the following examples didn't work either: $origImg = "uploads/" . $this->pic_name;$origImg = "uploads/{$this->pic_name}"; I echoed out the variables to see if they contain the proper values and they do as well. I even tried to cast them to strings like the following and still get fail on copy: $imgToCopy = (string)"uploads/$this->pic_name";$setAsOrig = (string)"uploads/$this->pic_name" . ".orig"; It works though when setting the variables like the following: $imgToCopy = "uploads/sfsGDFDmyimage.jpg";$setAsOrig = "uploads/sfsGDFDmyimage.jpg" . ".orig";

Edited by Don E
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...