私のコード:
意見
<?php echo form_open_multipart('projects/create') ?>
<label for="pro_video">Project Image</label>
<?php echo form_upload(array('name'=>'pro_image', 'type'=>'file', 'multiple'=>'multiple', 'accept'=>'image/*'))?>
<input type="submit" name="create_project" value="Create" />
</form>
コントローラ
public function __construct()
{
parent::__construct();
$this->load->library('image_lib');
$this->load->helper(array('form', 'url', 'html'));
$this->load->library('form_validation');
}
public function create()
{
if( sizeof($_FILES['pro_image']) > 0 ){
$config['upload_path'] = './test_upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->image_lib->initialize($config);
for( $i = 0; $i < sizeof($_FILES['pro_image']['name']); $i++ ){
$this->upload->do_upload('pro_image');
}
}
}
しかし、それは最後の画像をアップロードします.. :(
var_dump($_FILES):
array(1) {
["pro_image"]=>
array(5) {
["name"]=>
array(2) {
[0]=>
string(10) "Desert.jpg"
[1]=>
string(10) "Tulips.jpg"
}
["type"]=>
array(2) {
[0]=>
string(10) "image/jpeg"
[1]=>
string(10) "image/jpeg"
}
["tmp_name"]=>
array(2) {
[0]=>
string(23) "E:\wamp\tmp\phpA235.tmp"
[1]=>
string(23) "E:\wamp\tmp\phpA245.tmp"
}
["error"]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
["size"]=>
array(2) {
[0]=>
int(845941)
[1]=>
int(620888)
}
}
}