Как изменить URL-адрес ответа http://local/storage/public/img_src/img.jpg на http://local/img_src/img.jpg в люменах? - PullRequest
0 голосов
/ 10 июля 2020

Я получил такой ответ

{
    "name": "1594344029.jpeg",
    "file_path": "public/img_src/user_3",
    "type": "motif",
    "customer_id": 3,
    "updated_at": "2020-07-10 01:20:29",
    "created_at": "2020-07-10 01:20:29",
    "id": 108,
    "url": "http://localhost:8000/storage/public/img_src/user_3/1594344029.jpeg"
}

здесь мой код

            $filePath = base_path('public/img_src/' . $this->getUserDir());
            $fileResultPath = 'public/img_src/'.$this->getUserDir();
            $fileName = time().'.jpeg';

            if (!is_dir($filePath)) {
                mkdir($filePath);
            }
            $image = file_put_contents($filePath.'/'.$fileName, $data);
            if($image) {
                $generated =  $model::create([
                    'name' => $fileName,
                    'file_path' => $fileResultPath,
                    'type' => 'motif',
                    'customer_id' => Auth::id()
                ]);
                return response($generated);
            }

Изображение сохранено в /img_src/user_3, а в public нет каталога storage/public, поэтому я Предположим, что /storage/public в ответе URL-адреса является значением по умолчанию, как отредактировать ответ URL-адреса, чтобы ответ URL-адреса по умолчанию /storage/public был удален?

...