0
CodeIgniter에 사용자가 2 개의 파일을 업로드 할 수있는 양식이 있습니다. 백엔드에서는이 파일들을 다른 폴더에 저장하려고합니다. 컨트롤러에서 업로드 코드를 작성했습니다올바른 폴더에 파일이 저장되지 않음
public function upload()
{
/**Start uploading file**/
$config['upload_path'] = './assets/file/.';
$config['allowed_types'] = 'gif|jpg|png|doc|txt';
$config['max_size'] = 1024 * 8;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('file'))
{
$error = array('error' => $this->upload->display_errors());
echo $error;
}
else
{
$data = $this->upload->data();
echo $file = $data['file_name']; //name of file
}
/**End uploading file**/
/**Start uploading img**/
$config2['upload_path'] = './assets/img/.';
$config2['allowed_types'] = 'gif|jpg|png|doc|txt';
$config2['max_size'] = 1024 * 8;
$config2['encrypt_name'] = TRUE;
$this->load->library('upload', $config2);
if (!$this->upload->do_upload('img'))
{
$error1 = array('error' => $this->upload->display_errors());
echo $error1;
}
else
{
$data1 = $this->upload->data();
echo $img = $data1['file_name']; //name of img
}
/**End uploading img**/
}
이미지가 업로드되고 있지만 같은 폴더에 업로드 중입니다.
이$this->upload->initialize($config2);
이미지는 다음과 같습니다 부하 방법은 초기화하지 않기 때문에 사람이 내가 파일을 별도의 폴더 두 번째 부하 –