업로드하는 데 사용중인 컨트롤러에서 업로드 라이브러리의 옵션을 다시 정의하고 다시 초기화하면됩니다.
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);
이 좀 더이 가능하다 당신이에보고 한 후 그
UPDATE에게
를 다시 실행해야합니다, 그래서 당신은 내가 확신 모든 사전 정의 된 설정 항목을 잃게됩니다
. Upload
라이브러리를 보면 내부에 함수가있어 set
변수 중 일부가 있습니다. 모두에 대해 set
기능이 없으며 모두 사용할 수있는 set
기능이 아닐 수 있습니다. 그래서 당신은 이런 것을 할 수 있습니다. 같이
$this->load->library("Upload"); // loads upload library with predefined config items in config/upload.php
//to change upload path
$this->upload->set_upload_path("new location");
//CANNOT DO THIS BECAUSE ITS USED IN do_upload function you would need to extend the upload library and create your own set function.
$this->upload->set_filename("new filename");
$this->upload->do_upload();
기타 값
내가하고 싶은 게 아니에요
set_max_filesize
set_max_filename
set_max_width
set_max_height
set_allowed_types
을 설정하는 데 사용할 수 있습니다. 난 그냥 특정 구성 값을 무시하고 싶습니다. 업로드 할 때마다이 작업을 수행하려고하면 /config/upload.php를 사용할 필요가 없습니다. – StackOverflowNewbie
@StackOverflowNewbie 내 대답을 업데이트했습니다 – Henesnarfel
@Henesnarfel 그 위대한 일했습니다. 고맙습니다. :) 허용 된 파일 형식을 재정의하기 위해 abmove 메서드를 사용했습니다. – fl3x7