파일업로드후 페이지이동

파일업로드후 페이지이동

QA

파일업로드후 페이지이동

답변 1

본문

영카트에서 기존슬라이드를 제거하고 다른슬라이드로 바꿔서 배너 이미지 업로드 소스를 새로 만들고 있습니다. bannerlist.php에서 파일 업로드하는대

slideupdate.php 파일에서 업로드를 처리해려고합니다.

파일은 img폴더에 저장되게끔 만들었는대 파일업로드가 안됩니다. 

 


    <form method="post" enctype="multipart/form-data" action="./slideupdate.php">
        <input type="file" name="it_slide1"  id="it_slide1" value="<?php echo get_text($it['it_slide1']); ?>" id="it_slide1" class="frm_input" >  <label for="it_slide1_del"><span class="sound_only">배너1 </span>파일삭제</label> 
         <input type="checkbox" name="it_slide1_del" id="it_slide1_del" value="1"> 
         <button>확인</button>
         </form>

 

slideupdate.php


<?php
// 설정
$uploads_dir = (G5_IMG_PATH); 
$allowed_ext = array('jpg','jpeg','png','gif');
 
// 변수 정리
$error = $_FILES['it_slide1']['error'];
$name = $_FILES['it_slide1']['name'];
$ext = array_pop(explode('.', $name));
 
// 오류 확인
if( $error != UPLOAD_ERR_OK ) {
    switch( $error ) {
        case UPLOAD_ERR_INI_SIZE:
        case UPLOAD_ERR_FORM_SIZE:
            echo "파일이 너무 큽니다. ($error)";
            break;
        case UPLOAD_ERR_NO_FILE:
            echo "파일이 첨부되지 않았습니다. ($error)";
            break;
        default:
            echo "파일이 제대로 업로드되지 않았습니다. ($error)";
    }
    exit;
}
 
// 확장자 확인
if( !in_array($ext, $allowed_ext) ) {
    echo "허용되지 않는 확장자입니다.";
    exit;
}
 
// 파일 이동
move_uploaded_file( $_FILES['it_slide1']['tmp_name'], "$uploads_dir/$name");
?>

이 질문에 댓글 쓰기 :

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 29
© SIRSOFT
현재 페이지 제일 처음으로