开发者

PHP - How to copy a file to other location?

I need to develop a PHP script that will be able to select files from the server to copy them to the same server but 开发者_高级运维to another directory.

I need to select the file like if I was selecting a file from my local computer.

This is possible? What steps should I take to begin with this script? There are any tutorials out there that exemplifies this scenario?

Best Regards,

Sorry for my English.


Use CKFinder or copy().


copy($sourceFile, $destinationFile);

If $destinationFile exists, it will be overwritten.

UPDATE:

To read the filelist in a specific directory you can use this function:

function dirlist($directory){

    if (is_dir($directory)){

        if ($handle = opendir($directory)){

            while (($file = readdir($handle)) !== false){
                $files[] = $file;
            }

            closedir($handle);
        }
    }
    return $files;

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜