2
我有這樣的代碼在笨文件上載:Codeigniter - 如何上傳帶縮略圖的原始圖像?
if(!empty($_FILES['userfile'])){
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key => $value)
for ($s=0; $s<=$count-1; $s++){
$_FILES['userfile']['name'] = $value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './public/images/campaign-images/';
$config['allowed_types'] = 'gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG';
$config['max_size'] = '10000';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$CI->load->library('upload', $config);
$CI->upload->do_upload();
$data = $CI->upload->data();
$name_array[] = $data['file_name'];
}
return $name_array;
}
此代碼工作完美單原圖上傳,但如何上傳圖片縮略圖像(350×250),具有不同的文件夾中調整大小。
任何想法如何處理codeigniter庫?
感謝
謝謝大家對我的支持。我已添加您的代碼,但無法在拇指文件夾中看到上傳的文件。 –
只需修改源圖像路徑如下 $ config ['source_image'] = $ value ['name'] [$ s]; –
在哪裏添加? –