Several ways to download Codeigniter files

I am creating an application that should download downloaded files and put them in separate directories for thumbnails and full-size images. But $ config ['upload_path'] = './uploads/'; only allows me to choose one download path. How to identify two or more download paths?

+3
source share
3 answers

In fact, all you have to do is “reinitialize” the load class. Codeigniter does not allow you to call a class twice with new parameters (it ignores the second request), however you can say that the class manually loads the new parameters. Here is the basic information: (note the line "$ this-> upload-> initialized ($ config)". This is the key.

// this is for form field 1 which is an image....
$config['upload_path'] = './uploads/path1';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->upload->initialize($config); 
$this->upload->do_upload($fieild_1);

// this is for form field 2 which is a pdf
$config['upload_path'] = './pdfs/path2';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '300';
$this->upload->initialize($config); 
$this->upload->do_upload($fieild_2);

I wrote the whole article about it here: http://taggedzi.com/articles/display/multiple-file-uploads-using-codeigniter

script, . , , . ( , ...)

, .

+11

. .

, . :

/images/member/1
/images/member/2
/images/member/3

$config['upload_path'] = "/images/member/$user_id";

-, , . , $config ['upload_path'] , :

/images/member/1/resized
/images/member/1/thumbnails

. , $config ['upload_path'] , .

0

( ) : CodeIgniter , 1 .

- .

-1

Source: https://habr.com/ru/post/1763489/


All Articles