Move multiple . xml files to another PHP directory

Asked

Viewed 314 times

2

Current directory

Xmls/multiple files here....

I want to pass all files from inside Xmls to

Xmls/Xmlslidos

I tried to do with copy and then use unlink, but it didn’t work out.

  • Give a look http://answall.com/questions/121314/como-mover-arquivos-com-copy-do-php, it might help.

  • This way it is in the answer of this question, only passes the file if you indicate the name and pass only one file. My problem would be with several.

1 answer

1


It is a process that can be done with the function, glob and name:

<?php

    // pega a lista de arquivos com a extensão xml.
    $list = glob(__dir__.'/xml/*.xml');

    // diretorio aonde serão remanejados. 
    $save = __dir__.'/xmllido/';

    foreach ($list as $value) {
        if (rename($value, $save.basename($value))) {
            echo 'item enviado com exito';
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.