Add NAS file manager integration and all pending platform changes
- Installed p7h/nas-file-manager package via private VCS repo - Published config/nas-file-manager.php with super_admin middleware restriction - Added NAS env vars to .env.example - Created admin/nas-storage page with connection info panel and file browser widget - Added NAS Storage link to admin sidebar (super_admin only) - Added SuperAdminController@nasStorage method and admin.nas-storage route - Includes all accumulated branch changes: profile wall, 2FA, audit logs, settings panel, country/phone/timezone components, posts, slideshow, playlist shares, video downloads/shares, comment likes, notifications, social links, and more Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
d44490dfe0
commit
0b2e95ea65
161 files changed
+27496
-7250
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ImageUploadController extends Controller
|
||||
{
|
||||
public function upload(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'image' => 'required|string',
|
||||
'folder' => 'required|string|max:80',
|
||||
'filename' => 'required|string|max:200',
|
||||
]);
|
||||
|
||||
$imageData = $request->image;
|
||||
$parts = explode(';base64,', $imageData);
|
||||
$typePart = explode('image/', $parts[0]);
|
||||
$extension = $typePart[1] ?? 'png';
|
||||
// Sanitize extension
|
||||
$extension = preg_replace('/[^a-z0-9]/', '', strtolower($extension));
|
||||
if (!in_array($extension, ['png', 'jpg', 'jpeg', 'webp', 'gif'])) {
|
||||
$extension = 'png';
|
||||
}
|
||||
|
||||
$imageBinary = base64_decode($parts[1] ?? '');
|
||||
if (!$imageBinary) {
|
||||
return response()->json(['success' => false, 'message' => 'Invalid image data'], 422);
|
||||
}
|
||||
|
||||
$folder = trim($request->folder, '/');
|
||||
$fileName = $request->filename . '.' . $extension;
|
||||
$fullPath = $folder . '/' . $fileName;
|
||||
|
||||
Storage::disk('public')->put($fullPath, $imageBinary);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $fullPath,
|
||||
'url' => asset('storage/' . $fullPath),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user