0

在视图中访问数组时出现问题....

这是控制器中的功能

public function go() 
{
if(isset($_POST['go']))
{

  $config['upload_path'] = './uploads/'; /* NB! create this dir! */
  $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
  $config['max_size']  = '1000';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';
  /* Load the upload library */
  $this->load->library('upload', $config);

  /* We have 3 files to upload

   */
  for($i = 1; $i < 4; $i++) {
    /* Handle the file upload */
    $this->upload->do_upload('files'.$i);

    /* Get the data about the file */
    $data = $this->upload->data();

    $datta = array('upload_data' => $this->upload->data());
    echo "<br>";
    echo "<br>";
    print_r($datta);


 }
}

/* And display the result page */
$this->load->view('image_upload_result', $datta);

}

这是我的看法......

<?php echo form_open_multipart('users/go');?>
<input type="file" name="files1" /><br />
        <input type="file" name="files2" /><br />
        <input type="file" name="files3" />
<br /><br />

<input type="submit" name="go" value="upload" />
</form>

这是结果页面……函数 go() 上传了三张图片,但它只显示一张记录或一张图片……我已经尝试了不同的方法和循环条件,但徒劳无功……请任何人帮助我...提前致谢

<?php


foreach($upload_data as $value)
{
print_r($value);
echo "<br>";
echo "<br>";

}

?>

还有一件事…… print_r($datta); 在函数中打印以下内容

Array ( [upload_data] => Array ( [file_name] => Lighthouse3.jpg [file_type] => image/jpeg [file_path] => C:/wamp/www/CI/uploads/ [full_path] => C:/wamp/www/CI/uploads/Lighthouse3.jpg [raw_name] => Lighthouse3 [orig_name] => Lighthouse.jpg [client_name] => Lighthouse.jpg [file_ext] => .jpg [file_size] => 548.12 [is_image] => 1 [image_width] => 1024 [image_height] => 768 [image_type] => jpeg [image_size_str] => width="1024" height="768" ) )
Array ( [upload_data] => Array ( [file_name] => Koala3.jpg [file_type] => image/jpeg [file_path] => C:/wamp/www/CI/uploads/ [full_path] => C:/wamp/www/CI/uploads/Koala3.jpg [raw_name] => Koala3 [orig_name] => Koala.jpg [client_name] => Koala.jpg [file_ext] => .jpg [file_size] => 762.53 [is_image] => 1 [image_width] => 1024 [image_height] => 768 [image_type] => jpeg [image_size_str] => width="1024" height="768" ) )
Array ( [upload_data] => Array ( [file_name] => Penguins3.jpg [file_type] => image/jpeg [file_path] => C:/wamp/www/CI/uploads/ [full_path] => C:/wamp/www/CI/uploads/Penguins3.jpg [raw_name] => Penguins3 [orig_name] => Penguins.jpg [client_name] => Penguins.jpg [file_ext] => .jpg [file_size] => 759.6 [is_image] => 1 [image_width] => 1024 [image_height] => 768 [image_type] => jpeg [image_size_str] => width="1024" height="768" ) ) 
4

1 回答 1

0

使用pl上传器进行多次上传

于 2013-05-23T12:33:54.223 回答