Corrected function:
function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}
Question
I have following Array with filenames. Array is saved under var $files.
array (
[0] => DSC02425.jpg
[1] => DSC02426.jpg
[2] => DSC02432.jpg
[3] => DSC02437.jpg
)
I want to copy this files from one to another folder, but how can i achive this? I made a function but it isnt working:
function copyFiles($array) {
for ($i = 0;$i < count($array);$i ++) {
copy("./" . $array[$i] , "/$folderlabel/" . $array[$i]);
}
}
copyFiles($files);
La solution
Corrected function:
function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}