Pabs
(Pevweb)
1
Trying to copy a file from one location to another and I keep getting this error
[<a href='function.copy'>function.copy</a>]: failed to open stream: No such file or directory
both the folder with the image and the destination folder have full read-write access.
here’s the simple code i’m trying execute
$basefile = Yii::app()->baseUrl.'/images/users/img.jpg';
$targetfle =Yii::app()->baseUrl.'/images/users/gen/img_copy.jpg';
if(copy($basefile,$targetfle))
return "success";
else
return "fail";
what else could be going on to cause this?
phtamas
(Phtamas)
2
Use file system paths as parameters for file system functions. Web URLs are not likely to work in this case.
Yii::app()->basePath . '/images/users/img.jpg';
EDIT: Path aliases also can be used:
Yii::getPathOfAlias('webroot.images.users') . '/img.jpg'
Pabs
(Pevweb)
3
awesome… never even thought of that… works like a charm
thanks!