laravel文件系统

<?php

public function file(){

        //$str = "L3VwbG9hZC8zLmpwZywvdXBsb2FkLzIuanBn";
        //echo "<pre>";
        //print_r(base64_decode($str));
        //echo "</pre>";
        //sftp上传文件
        Storage::disk('siyu_tmp')->put('/newdir/1.txt', "hello the world!");

        //日志
        /*
        Log::debug('An informational message.');
        $message = "log message";
        Log::emergency($message);
        Log::alert($message);
        Log::critical($message);
        Log::error($message);
        Log::warning($message);
        Log::notice($message);
        Log::info($message);
        Log::debug($message);

        $id = 1;
        Log::info('Showing user profile for user: '.$id);
        Log::info('User failed to login.', ['id' => 1]);

        Log::channel('slack')->info('Something happened!');
        Log::stack(['single', 'slack'])->info('Something happened!');
        */
        //创建文件
        //Storage::disk('local')->put('file.txt', 'Contents');
        //取文件内容
        //$contents = Storage::get('file.txt');
        //print_r($contents);
        //echo "<br>";
        //$url = Storage::url('file.txt');
        //echo "url=>".$url."<br>";
        //Storage::prepend('file.txt', 'Prepended Text');
        //Storage::append('file.txt', 'Appended Text');

        //删除文件
        //Storage::delete('1.txt');
        //Storage::delete(['1.txt', '2.txt']);

        //文件夹
        //Storage::makeDirectory("one");
        //Storage::deleteDirectory("one");

        //自动创建文件夹
        //Storage::copy('1.txt', 'dir/one.txt');
        //Storage::move('1.txt', 'directory/1.txt');

        //列表文件
        $files = Storage::files("dir");
        echo "<pre>";
        print_r($files);
        echo "</pre>";

        $files = Storage::allFiles("dir");
        echo "<pre>";
        print_r($files);
        echo "</pre>";

        $directories = Storage::directories("dir");
        echo "<pre>";
        print_r($directories);
        echo "</pre>";

        //递归
        $directories = Storage::allDirectories("dir");
        echo "<pre>";
        print_r($directories);
        echo "</pre>";

    }

?>

    A+
发布日期:2018年05月29日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: