필요한만큼 파일을 추가 할 수있는 업로드 양식이 있습니다. 그러나 파일을 업로드하려고 할 때 오류가 발생합니다.Codeigniter, 같은 이름의 여러 파일 업로드
Array ([0] => license.txt [1] => license.txt)
내가 업로드가 작동하는 방법에 완전히 붙어 오전 :
$this->load->library('upload');
$error = "";
$file = "";
$this->total_count_of_files = count($_FILES['user_certificates']['name']);
print_r($_FILES['user_certificates']['name']);
for($i=0; $i<$this->total_count_of_files; $i++)
{
$_FILES['user_certificates']['name'] = $_FILES['user_certificates']['name'][$i];
$_FILES['user_certificates']['type'] = $_FILES['user_certificates']['type'][$i];
$_FILES['user_certificates']['tmp_name'] = $_FILES['user_certificates']['tmp_name'][$i];
$_FILES['user_certificates']['error'] = $_FILES['user_certificates']['error'][$i];
$_FILES['user_certificates']['size'] = $_FILES['user_certificates']['size'][$i];
$config['encrypt_name'] = TRUE;
$config['file_name'] = $_FILES['user_certificates']['name'];
$config['upload_path'] = './certificate_files/';
$config['allowed_types'] = 'txt|pdf|doc|docx';
$config['max_size'] = 0;
$this->upload->initialize($config);
if (!$this->upload->do_upload())
{
$status = 'error';
$msg = $this->upload->display_errors();
}
else
{
$data = $this->upload->data();
$file = $data['raw_name'] . $data['file_ext'];
}
if($file)
{
$status = "success";
$msg = "Image successfully uploaded";
}
else
{
$status = "error";
$msg = "Something went wrong when saving the image, please try again.";
}
}
echo json_encode(array('status' => $status, 'msg' => $msg));
exit();
print_r($_FILES['user_certificates']['name']))
컨트롤러는 나에게 내가 추가 한 파일을 보여줍니다. 어떤 아이디어?
미리 환호하십시오!
편집
나는 변경하는 경우이 : 이것에
if (!$this->upload->do_upload())
:
if (!$this->upload->do_upload('user_certificates'))
작동하지만, 단 하나 개의 파일에 대해, 그것은 다시 루프 라운드로하지 않는 것 어떤 이유로
d ** 오류 ** 무엇이 발생하고 있습니까 ??? –
파일이 어떤 폴더에도 업로드되지 않고 'echo json_encode (array ('status '=> $ status,'msg '=> $ msg)); '{ "상태": "오류", "msg": "파일을 저장할 때 문제가 발생했습니다. 다시 시도하십시오."}'. 따라서 오류는 config가 초기화 된 후에 발생합니다. 어떤 생각? – Pooshonk
파일이 업로드되고있는 것 같지만'$ data [ 'raw_name']'에 대한 값을 어디에서 설정하고 있습니까? –