fix:법인도장 업로드를 base64 방식으로 변경 (PHP upload_max_filesize 제한 우회)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-13 16:44:12 +09:00
parent e8d494a081
commit fe9716ff17
2 changed files with 18 additions and 8 deletions

View File

@@ -54,11 +54,15 @@ public function getStamp(): JsonResponse
public function uploadStamp(Request $request): JsonResponse
{
$request->validate([
'stamp_image' => 'required|image|max:5120',
'stamp_image_data' => 'required|string',
]);
$tenantId = session('selected_tenant_id', 1);
$file = $request->file('stamp_image');
$imageData = base64_decode($request->input('stamp_image_data'));
if (!$imageData) {
return response()->json(['success' => false, 'message' => '이미지 데이터가 올바르지 않습니다.'], 422);
}
$path = "esign/{$tenantId}/stamps/company_stamp.png";
@@ -67,7 +71,7 @@ public function uploadStamp(Request $request): JsonResponse
Storage::disk('local')->delete($path);
}
Storage::disk('local')->put($path, file_get_contents($file->getRealPath()));
Storage::disk('local')->put($path, $imageData);
TenantSetting::updateOrCreate(
[

View File

@@ -388,20 +388,26 @@ className={`px-3 py-1 text-sm rounded ${p === pagination.current_page ? 'bg-blue
const handleUpload = async (e) => {
const file = e.target.files[0];
if (!file) return;
if (file.size > 5 * 1024 * 1024) { alert('파일 크기는 5MB 이하여야 합니다.'); return; }
setUploading(true);
try {
const fd = new FormData();
fd.append('stamp_image', file);
const base64 = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result.split(',')[1]);
reader.onerror = reject;
reader.readAsDataURL(file);
});
const res = await fetch('/esign/contracts/stamp', {
method: 'POST',
headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': csrfToken },
body: fd,
headers: { ...getHeaders(), 'Content-Type': 'application/json' },
body: JSON.stringify({ stamp_image_data: base64 }),
});
const json = await res.json();
if (json.success) {
setStamp(json.data);
} else {
alert(json.message || '업로드에 실패했습니다.');
const errMsg = json.errors?.stamp_image_data?.[0] || json.message || '업로드에 실패했습니다.';
alert(errMsg);
}
} catch (e) { alert('업로드 중 오류가 발생했습니다.'); }
setUploading(false);