国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

打包bin文件后,無法打開public下的文件

fanyin

問題描述

app/config.php 下配置了 'public_path' => base_path(false) . DIRECTORY_SEPARATOR . 'public',

上傳excel文件到public指定目錄下可以

但是讀取文件時候出錯

$allFilePath = public_path('/storage/'.$filePath);  //第一行是文件路徑

$allSheets = Excel::import($realPath)->toArray();  //這一行就報錯了,在本地可以,一切正常

采用的讀取excel庫是 dcat/easy-excel 1.1版本

也按照網(wǎng)上的教程 function.php 里寫了一個函數(shù):

function get_public_resource_path($path)
{
    static $resourcePathMap = [];
    if (!\class_exists(\Phar::class, false) || !\Phar::running()) {
        return $path;
    }
    $tmpPath = runtime_path() . DIRECTORY_SEPARATOR . 'temp';
    if (!is_dir($tmpPath)) {
        mkdir($tmpPath);
    }
    $filePath = $tmpPath . DIRECTORY_SEPARATOR . basename($path);
    clearstatcache();
    if (!isset($resourcePathMap[$path]) || !is_file($filePath)) {
        file_put_contents($filePath, file_get_contents($path));
        $resourcePathMap[$path] = $filePath;
    }
    return $resourcePathMap[$path];
}

在使用的時候

$allFilePath = public_path("/storage/". $filePath);

$realPath = get_public_resource_path($allFilePath);

$allSheets = Excel::import($realPath)->toArray();

依然報錯,請求大佬指點迷津!

811 0 0
0個回答

年代過于久遠,無法發(fā)表回答
??
    1. <bdo id="nmuxo"></bdo>
      <rt id="nmuxo"></rt>