60
задан 1 December 2014 в 19:37

1 ответ

я Работал над laravel Проектом С Генератором Грязи, и этот Метод не Работает

@aqm, таким образом, я создал свою собственную функцию

Путь PHP

function forceFilePutContents (string $fullPathWithFileName, string $fileContents)
    {
        $exploded = explode(DIRECTORY_SEPARATOR,$fullPathWithFileName);

        array_pop($exploded);

        $directoryPathOnly = implode(DIRECTORY_SEPARATOR,$exploded);

        if (!file_exists($directoryPathOnly)) 
        {
            mkdir($directoryPathOnly,0775,true);
        }
        file_put_contents($fullPathWithFileName, $fileContents);    
    }

, ПУТЬ LARAVEL

не забывает добавлять наверху файла

use Illuminate\Support\Facades\File;

function forceFilePutContents (string $fullPathWithFileName, string $fileContents)
    {
        $exploded = explode(DIRECTORY_SEPARATOR,$fullPathWithFileName);

        array_pop($exploded);

        $directoryPathOnly = implode(DIRECTORY_SEPARATOR,$exploded);

        if (!File::exists($directoryPathOnly)) 
        {
            File::makeDirectory($directoryPathOnly,0775,true,false);
        }
        File::put($fullPathWithFileName,$fileContents);
    }
0
ответ дан 1 November 2019 в 09:59

Другие вопросы по тегам:

Похожие вопросы: