댓글에 사진 올릴려고 짠 소스인데 안되네요? 뭐가 잘못된는지 좀 봐주세요 채택완료
$total = count($_FILES['photo_file']['name']);
// Loop through each file for($i=0; $i<$total; $i++) { //Get the temp file path $tmpFilePath = $_FILES['photo_file']['tmp_name'][$i];
//Make sure we have a filepath if ($tmpFilePath != ""){ //Setup our new file path $newFilePath = "./uploadFiles/" . $_FILES['photo_file']['name'][$i];
//Upload the file into the temp dir if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
} } }
if ($_FILES["photo_file"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; }
$allowed = array('gif','png' ,'jpg'); $filename = $_FILES['photo_file']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); if(!in_array($ext,$allowed) ) { $uploadOk = 0; }
?>
/>
답변 1개
파일을 업로드 처리하는 페이지에서
print_r($_FILES['photo_file']) 또는
print_r($_FILES) 해보세여
위 명령어에서 값들이 나오면 파일은 읽혔다고 보면됩니다.
파일이 올라오는 부분은 해당 위치에 파일 확인하면 되겠습니다.
권한등 체크하시구여
답변에 대한 댓글 2개
gif라고 되어있지만
밑에 gif png jpg가 있어서 안고쳤어요 밑에게 먹을거같아서
allowed = array('gif','png' ,'jpg');
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$newFilePath = G5_DATA_PATH.'/uploadFiles/'.substr($member['mb_id'],0,2).'/'.$member['mb_id'].'.gif';
이거 추가 햇고
print_r($_FILES['photo_file'])
이것도 추가했어요
그리고 /board/mobile/skin/board/basic/uploadFiles uploadfiles는 이렇게 폴더를 만들었고
/board/mobile/skin/board/basic basic 안에 list.skin.php/view.skin.php/view_comment.skin.php/write.skin.php 이렇게 들어있습니다
<?
$newFilePath = G5_DATA_PATH.'/uploadFiles/'.substr($member['mb_id'],0,2).'/'.$member['mb_id'].'.gif';
$total = count($_FILES['photo_file']['name']);
// Loop through each file
for($i=0; $i<$total; $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['photo_file']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "/uploadFiles/" . $_FILES['photo_file']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}
if ($_FILES["photo_file"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
$allowed = array('gif','png' ,'jpg');
$filename = $_FILES['photo_file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed) ) {
$uploadOk = 0;
}
print_r($_FILES['photo_file'])
?>