이미지 파일 업로드 경로 질문입니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
이미지 파일 업로드 경로 질문입니다.

QA

이미지 파일 업로드 경로 질문입니다.

본문

 

  // Get the Gnu Board 5 data path

    $data_path = "/var/www/주소/data/";

 

    // Directory for file uploads within the data path

    $upload_directory = 'file/request/';

 

    // Final destination path for the uploaded files

    $destination_path = $data_path . $upload_directory;

 

  // rq_thumb1, rq_thumb2 및 rq_thumb3에 대해 업로드된 이미지 이동(파일 입력을 사용하여 업로드된 것으로 가정)

  if ($_FILES['rq_thumb1']['error'] === UPLOAD_ERR_OK) {

    $file_name = basename($_FILES['rq_thumb1']['name']);

    $target_path = "$destination_path{$last_insert_id}_thumb1_{$file_name}";

    moveUploadedFile($_FILES['rq_thumb1']['tmp_name'], $target_path);

    // Update the database with the file path

    $stmt_update = $conn->prepare("UPDATE `g5_request` SET `rq_thumb1` = ? WHERE `rq_no` = ?");

    $stmt_update->bind_param("si", $target_path, $last_insert_id);

    $stmt_update->execute();

    $stmt_update->close();

}

 

if ($_FILES['rq_thumb2']['error'] === UPLOAD_ERR_OK) {

    $file_name = basename($_FILES['rq_thumb2']['name']);

    $target_path = "$destination_path{$last_insert_id}_thumb2_{$file_name}";

    moveUploadedFile($_FILES['rq_thumb2']['tmp_name'], $target_path);

    // Update the database with the file path

    $stmt_update = $conn->prepare("UPDATE `g5_request` SET `rq_thumb2` = ? WHERE `rq_no` = ?");

    $stmt_update->bind_param("si", $target_path, $last_insert_id);

    $stmt_update->execute();

    $stmt_update->close();

}

 

if ($_FILES['rq_thumb3']['error'] === UPLOAD_ERR_OK) {

    $file_name = basename($_FILES['rq_thumb3']['name']);

    $target_path = "$destination_path{$last_insert_id}_thumb3_{$file_name}";

    moveUploadedFile($_FILES['rq_thumb3']['tmp_name'], $target_path);

    // Update the database with the file path

    $stmt_update = $conn->prepare("UPDATE `g5_request` SET `rq_thumb3` = ? WHERE `rq_no` = ?");

    $stmt_update->bind_param("si", $target_path, $last_insert_id);

    $stmt_update->execute();

    $stmt_update->close();

}

 

  echo "Data insertion succeeded.";

} else {

  echo "Error: " . $stmt->error;

}




따로 썸네일을 등록할수있게 이미지파일을 db랑 파일내에 저장할려고 합니다

파일경로에 새 디렉토리 request는 만들었는데, 파일 저장은 안되고 db에 링크만 저장이 되네요. 이런식으로 하는게 맞는건가요?

이 질문에 댓글 쓰기 :

답변을 작성하시기 전에 로그인 해주세요.
전체 1,108
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT