e9cbf23ab5
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
4.3 KiB
4.3 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| php-file-upload | PHP File Upload | Programming_Language | draft | conceptual |
|
B | 0.9 | 2026-07-04 | 2026-07-04 |
|
|
PHP File Upload
🎯 한 줄 통찰 (One-line insight)
Checking a file's extension alone is NOT proof it's a real image — the tutorial uses getimagesize() specifically to detect "fake images" (files renamed with an image extension but containing different content), showing that upload validation needs content-based checks, not just filename-based ones. [S1]
🧠 핵심 개념 (Core concepts)
- Required setup —
file_uploads = Onin php.ini; HTML form must havemethod="post"ANDenctype="multipart/form-data". [S1] $_FILES["fieldname"]— array holding uploaded file info:["name"],["tmp_name"],["size"]. [S1]getimagesize()— detects whether an uploaded file is a genuine image (vs. a renamed fake). [S1]file_exists()— checks for filename collisions before saving. [S1]pathinfo($file, PATHINFO_EXTENSION)— extracts the file extension for type-checking. [S1]move_uploaded_file($tmp_name, $target)— the final step that actually relocates the uploaded file from its temporary location to the destination. [S1]$uploadOkflag pattern — accumulates validation failures across multiple checks (file exists, size limit, file type) before deciding whether to actually move the file. [S1]
📖 세부 내용 (Details)
- Form requirements:
<form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="fileToUpload"> <input type="submit"> </form>. [S1] - Real-image check:
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; }. [S1] - Size limit (500KB):
if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; }. [S1] - Type whitelist:
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $uploadOk = 0; }. [S1] - Final move:
if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "uploaded."; } }. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
- 확장자만으로는 불충분: getimagesize()로 실제 이미지 콘텐츠인지 확인해야 하며, 확장자 이름만으로는 가짜 이미지를 걸러낼 수 없다는 점이 강조됨. [S1]
🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 파일 존재 여부/크기/타입을 순차적으로 검사한 후 최종적으로 move_uploaded_file()로 이동하는 것이 안전한 업로드 처리의 표준 패턴이다. [S1]
💻 코드 패턴 (Code patterns)
Verifying the uploaded file is a genuine image (PHP):
if (isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
} else {
echo "File is not an image.";
}
}
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.90
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: PHP Tutorial
- 관련 개념: PHP File Create, PHP Cookies, PHP Filter
- 참조 맥락: 파일 처리 섹션의 마지막 — 쿠키(Cookies) 섹션으로 이어짐.
📚 출처 (Sources)
- [S1] W3Schools — PHP File Upload — https://www.w3schools.com/php/php_file_upload.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP File Upload" page (Astra wiki-curation, P-Reinforce v3.1 format).