본문 바로가기

웹/PHP

이미지 올리기

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>파일 업로드</title>
</head>
<body>
    <form method="post" action="ex32_upload.php"enctype="multipart/form-data"> 
        <input type="file" name="imagefile">
        <input type="submit">
    </form>
</body>
</html>


<!--  -->

<?php
//테스트 방법 : localhost/ex32_upload.php
// htdocs 폴더 밑에 images 폴더 생성해주세요 
    $upload_dir="images/";//현재 폴더 밑의 images 폴더에 올린다 
    $upload_file=$upload_dir.basename($_FILES['imagefile']['name']);

    if(move_uploaded_file($_FILES['imagefile']['tmp_name'], $upload_file)){
        echo "파일이 유효하고, 성공적으로 업로드 됨 "; 
    } else 
    {
        echo "파일 업로드가 실패함";
    }
    print_r($_FILES); // 정보 출력 
?>

' > PHP' 카테고리의 다른 글

JSON  (0) 2019.11.18
POST-OBCJECT  (0) 2019.11.18
mysql 연동 - user table  (0) 2019.11.18
배열~함수  (0) 2019.11.15
변수~ 배열  (0) 2019.11.14