Pregunta

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);
¿Fue útil?

Solución

Corrected function:

function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
    copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top