Update: 2026-05-04 02:20:59
This commit is contained in:
@@ -24,10 +24,22 @@ if ($decoded['role'] !== 'super_admin' && $invoice['tenant_id'] !== $decoded['te
|
||||
}
|
||||
|
||||
$filePath = $invoice['original_file_path'];
|
||||
if (!file_exists($filePath)) die('File missing');
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
error_log("FILE PROXY ERROR: File not found at " . $filePath);
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit('File missing');
|
||||
}
|
||||
|
||||
if (!is_readable($filePath)) {
|
||||
error_log("FILE PROXY ERROR: File not readable at " . $filePath);
|
||||
header("HTTP/1.0 403 Forbidden");
|
||||
exit('Permission denied');
|
||||
}
|
||||
|
||||
$mime = mime_content_type($filePath);
|
||||
header("Content-Type: $mime");
|
||||
header("Content-Length: " . filesize($filePath));
|
||||
header("Cache-Control: public, max-age=3600"); // Add caching for speed
|
||||
readfile($filePath);
|
||||
exit;
|
||||
|
||||
@@ -148,11 +148,11 @@
|
||||
<a :href="currentInvoice?.file_url" target="_blank" class="text-[10px] bg-gray-800 px-3 py-1 rounded hover:bg-gray-700 transition">تحميل الملف 📥</a>
|
||||
</div>
|
||||
<div class="flex-1 overflow-auto p-4 flex items-start justify-center scrollbar-hide">
|
||||
<template x-if="currentInvoice?.original_file_path?.endsWith('.pdf')">
|
||||
<template x-if="currentInvoice?.original_file_path?.toLowerCase().endsWith('.pdf')">
|
||||
<iframe :src="currentInvoice?.file_url" class="w-full h-full rounded-lg" frameborder="0"></iframe>
|
||||
</template>
|
||||
<template x-if="!currentInvoice?.original_file_path?.endsWith('.pdf')">
|
||||
<img :src="currentInvoice?.file_url" class="max-w-full rounded-lg shadow-2xl border border-white/5">
|
||||
<template x-if="!currentInvoice?.original_file_path?.toLowerCase().endsWith('.pdf')">
|
||||
<img :src="currentInvoice?.file_url" @error="$el.src='https://placehold.co/600x800?text=Error+Loading+Image'" class="max-w-full rounded-lg shadow-2xl border border-white/5">
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user