여분필드1 내용삭제와 파일삭제법

여분필드1 내용삭제와 파일삭제법

QA

여분필드1 내용삭제와 파일삭제법

답변 1

본문

동영상을 업로드하면서 video테그를 각각 it_1, It_1_subj필드에 넣도록 만들었는대 상품수정페이지에서 파일삭제 체크박스를 채크후 확인을 누르면 동영상 파일과 필드에 들어있는 테그를 삭제하려면 어떻게 해야할까요?

이미지 삭제 테그를 가져와 수정해봤는대 하얀화면만 뜨네요.

방금  itemformupdate.php 소스에 it1_del로 잘못 넣어서 it_1_del로 변경했는대 이것도  오류겠지만

다른 오류가 더 있는건지 안되네요.

 

itemform.php


    <th scope="row"><label for="it_1">여분필드(동영상)</label></th>
    <td>
        <p>
        <input type="file" name="it_1"  id="it_1" value="<?php echo get_text($it['it_1']); ?>" id="it_1" class="frm_input" >  <label for="it_1_del"><span class="sound_only">동영상 <?php echo $i; ?> </span>파일삭제</label>
                <input type="checkbox" name="it_1_del" id="it_1_del" value="1">
        <td class="td_grpset">
        <?php if ($it['it_1_subj']) { ?> <label for="it_1_subj"><center><strong>동영상 미리 보기</strong><br>
        <?php echo $it['it_1_subj']; ?> </label> <?php } ?>    </center>      
        </td>
        </p>
    </td>
<br>

 

itemformupdate.php


// 여분필드1 설정
$uploads_dir = (G5_MEDIA_PATH);
$allowed_ext = array('webm','mp4');
 
// 여분필드1 변수 정리
$error = $_FILES['it_1']['error'];
$name = $_FILES['it_1']['name'];
$ext = array_pop(explode('.', $name));
$v_1 = "<video controls><source src='".G5_MEDIA_URL."/".$name."'></video>";
$v_2 = "<video width= '300' height= '200' controls><source src='".G5_MEDIA_URL."/".$name."'></video>";
// 여분필드1 파일 이동
move_uploaded_file( $_FILES['it_1']['tmp_name'], "$uploads_dir/$name");
//여분필드1 데이터베이스 등록(v1상품 페이지, v2상품수정 페이지 미리 보기)
$sql = "update g5_shop_item set it_1= '".addslashes($v_1)."' where it_id='$it_id'";
$sql = "update g5_shop_item set it_1_subj= '".addslashes($v_2)."' where it_id='$it_id'";
sql_query($sql);
//여분필드1 파일 데이터베이스 삭제
if ($it_1_del) {
$sql = " select it_1 it_1_subj
                from {$g5['g5_shop_item_table']}
                where it_id = '$it_id' ";                
    sql_fetch($sql);
    $file_it_1 = $uploads_dir'/'.$name;
    @unlink($file_it_1);
    $it_1 = '';
    $it_1_subj ='';
}

 

 

이 질문에 댓글 쓰기 :

답변 1


if($it_1_del) {
    sql_query("update {$g5['g5_shop_item_table']} SET `it_1` = '' and `it_1_subj` = '' WHERE it_id = '$it_id' ");
    @unlink($uploads_dir.'/'.$name);
}

이렇게 짜시면 될 것 같구요.

저 코드에서 오류나는 부분은 (올려주신 코드 기준) 아래 파일 23번째줄에 $uploads_dir과 '/' 사이에 .이 빠졌습니다. 오류 디버깅하시려면 display_errors를 키고 error_reporting(E_ALL)로 해주세요.

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