2016-05-14 10 views
0

私はdebianマシンを持っていて、私のサイトは/ var/www/laravel-site/folderにあります。 laravel-siteフォルダにはFILESとPUBLICフォルダがあります。ファイルをWebから読み取ることを防ぐために、ファイルをFILESフォルダに出力するにはどうすればよいですか?パブリックフォルダの上に出力する方法Laravel 5.1

答えて

2

私はbase_path()

簡単な使用例を助ける推測:

<?php 
    $file = base_path('FILES').'/people.txt'; 
    // Open the file to get existing content 
    $current = file_get_contents($file); 
    // Append a new person to the file 
    $current .= "John Smith\n"; 
    // Write the contents back to the file 
    file_put_contents($file, $current); 
?> 

function base_path($path = '')はLaravelのヘルパー関数です。 echo base_path('FILES');を使用するので、

function base_path($path = '') 
{ 
    return app()->basePath().($path ? '/'.$path : $path); 
} 

、ちょうどFILESフォルダ(または任意のパスあなたはLaravelのベースの内側に必要)を取得するには echo base_path();

を使用し、あなたの/var/www/laravel-siteフォルダを取得するには:これは、インストールのベースへのパスを取得します 出力されます/var/www/laravel-site/FILES

関連する問題