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

打包bin文件后,無(wú)法打開public下的文件

fanyin

問(wèn)題描述

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

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

但是讀取文件時(shí)候出錯(cuò)

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

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

采用的讀取excel庫(kù)是 dcat/easy-excel 1.1版本

也按照網(wǎng)上的教程 function.php 里寫了一個(gè)函數(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];
}

在使用的時(shí)候

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

$realPath = get_public_resource_path($allFilePath);

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

依然報(bào)錯(cuò),請(qǐng)求大佬指點(diǎn)迷津!

711 0 0
0個(gè)回答

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??