CI 묻고 답하기

제목 파일 업로드 관련 권한 질문입니다
카테고리 CIBOARD
글쓴이 보라색맛났어 작성시각 2020/10/21 17:09:30
댓글 : 4 추천 : 0 스크랩 : 0 조회수 : 8023   RSS

글쓰기를 하면서 파일을 업로드 하는데 자꾸 권한에 막혀 등록이 안 됩니다 ㅠㅠ

 

로직에 0644로 돼 있던 권한값을 0707로 바꿨을 때 로컬에서는 업로드가 됐는데 

 

파일을 서버에 적용시키고 해보니까 권한 때문에 업로드가 안 되네요;;;

(업로드할려는 폴더가 쓰기가 금지되어있습니다.)

서버상 경로 가보면 폴더 권한은 문제 없었습니다

 

원인이 궁금합니다 

 

if (is_dir($upload_path) === false) {
					mkdir($upload_path, 0707);
					$file = $upload_path . 'index.php';
					$f = @fopen($file, 'w');
					@fwrite($f, '');
					@fclose($f);
					@chmod($file, 0707);
				}
				$upload_path .= cdate('Y') . '/';
				if (is_dir($upload_path) === false) {
					mkdir($upload_path, 0707);
					$file = $upload_path . 'index.php';
					$f = @fopen($file, 'w');
					@fwrite($f, '');
					@fclose($f);
					@chmod($file, 0707);
				}
				$upload_path .= cdate('m') . '/';
				if (is_dir($upload_path) === false) {
					mkdir($upload_path, 0707);
					$file = $upload_path . 'index.php';
					$f = @fopen($file, 'w');
					@fwrite($f, '');
					@fclose($f);
					@chmod($file, 0707);
				}

				foreach ($_FILES['post_file']['name'] as $i => $value) {
					if ($value) {
						$uploadconfig = array();
						$uploadconfig['upload_path'] = $upload_path;
						$uploadconfig['allowed_types'] = element('upload_file_extension', $board)
							? element('upload_file_extension', $board) : '*';
						$uploadconfig['max_size'] = element('upload_file_max_size', $board) * 1024;
						$uploadconfig['encrypt_name'] = true;

						$this->upload->initialize($uploadconfig);
						$_FILES['userfile']['name'] = $_FILES['post_file']['name'][$i];
						$_FILES['userfile']['type'] = $_FILES['post_file']['type'][$i];
						$_FILES['userfile']['tmp_name'] = $_FILES['post_file']['tmp_name'][$i];
						$_FILES['userfile']['error'] = $_FILES['post_file']['error'][$i];
						$_FILES['userfile']['size'] = $_FILES['post_file']['size'][$i];

						if ($this->upload->do_upload()) {  //여기서 업로드가 안되서 else로 빠짐
							$filedata = $this->upload->data();

							$uploadfiledata[$i] = array();
							$uploadfiledata[$i]['pfi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
							$uploadfiledata[$i]['pfi_originname'] = element('orig_name', $filedata);
							$uploadfiledata[$i]['pfi_filesize'] = intval(element('file_size', $filedata) * 1024);
							$uploadfiledata[$i]['pfi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0;
							$uploadfiledata[$i]['pfi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0;
							$uploadfiledata[$i]['pfi_type'] = str_replace('.', '', element('file_ext', $filedata));
							$uploadfiledata[$i]['is_image'] = element('is_image', $filedata) ? element('is_image', $filedata) : 0;
						} else {
							$file_error = $this->upload->display_errors();
							break;
						}
					}
				}
			}

 

 다음글 안녕하세요 CI 4를 이용중입니다. 다름이 아니라 Po... (13)
 이전글 버튼 클릭 시 하나의 페이지에서 다른 테이블 출력 (2)

댓글

변종원(웅파) / 2020/10/21 17:15:26 / 추천 1

상위 폴더가 접근이 막혀있으면 하위폴더에 쓰기가 되어 있어도 안됩니다.

한대승(불의회상) / 2020/10/21 17:19:15 / 추천 1

0644를 0707로 바꾼 특별한 이유가 있을까요?

0747로 바꾸면 해결될것 같긴합니다.

보라색맛났어 / 2020/10/21 17:27:55 / 추천 0

변종원(웅파) / 경로 폴더를 삭제하고 다시 업로드하니 등록되네요ㅠ 감사합니다

 

한대승(불의회상) / 폴더생성할 때 707 주길래 그냥 그거에 따라 수정해봤었습니다 ㅎㅎ;; ㅠ 

한대승(불의회상) / 2020/10/21 17:48:00 / 추천 0
@보라색맛났어 특별한 이유가 없다면 0644로 유지하시는게 좋을것 같습니다.