Files
2026-06-29 13:00:18 +06:00

33 lines
1.0 KiB
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
class ManageFile
{
const DISK = 'public';
const RESOURCE_DIR = 'resources';
public function uploadFile($file_path,$file_name,$content){
Storage::disk(self::DISK)->put(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path.DIRECTORY_SEPARATOR.$file_name,$content);
}
public function uploadHTML($file_path,$file_name,$content){
Storage::disk(self::DISK)->put(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path.DIRECTORY_SEPARATOR.$file_name,$content);
}
public function getFile($file_path): string
{
if (!Storage::disk(self::DISK)->exists(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path)) {
return "";
}
return Storage::disk(self::DISK)->get(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path);
}
public function deleteFile($file_path){
return Storage::disk(self::DISK)->delete(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path);
}
}