Welcome Guest, Not a member yet? Register   Sign In
problem of image gellary displaying image
#1

[eluser]Rumel[/eluser]
my controller name is image.php:<?php

class Image extends Controller {

private $data = array(
'dir' => array(
'original' => 'assets/uploads/original/',
'thumb' => 'assets/uploads/thumbs/'
),
'total' => 0,
'images' => array(),
'error' => ''
);

public function __construct()
{
parent::Controller();
}

public function index($start = 0)
{
if ($this->input->post('btn_upload')) {
$this->upload();
}

$this->load->library('pagination');

$c_paginate['base_url'] = site_url('image/index');
$c_paginate['per_page'] = '9';
$finish = $start + $c_paginate['per_page'];

if (is_dir($this->data['dir']['thumb']))
{
$i = 0;
if ($dh = opendir($this->data['dir']['thumb'])) {
while (($file = readdir($dh)) !== false) {
// get file extension
$ext = strrev(strstr(strrev($file), ".", TRUE));
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png') {
if ($start <= $this->data['total'] && $this->data['total'] < $finish) {
$this->data['images'][$i]['thumb'] = $file;
$this->data['images'][$i]['original'] = str_replace('thumb_', '', $file);
$i++;
}
$this->data['total']++;
}
}
closedir($dh);
}
}

$c_paginate['total_rows'] = $this->data['total'];

$this->pagination->initialize($c_paginate);

$this->load->view('images/index', $this->data);
}
view(images/index):
[removed]
function changepic(img_src, obj) {
document["img_tag"].src = img_src;
var thumbs = document.getElementsByName("thumb");
for (var i = 0; i < thumbs.length; i++) {
var tmp_id = "thumb_" + i;
document.getElementById(tmp_id).setAttribute("class", "thumb");
}
document.getElementById(obj).setAttribute("class", "thumbclick");
var ori_img = img_src.replace("thumb_", "");
document.getElementById("detimglink").setAttribute("href", ori_img);
}
[removed]
&lt;/head&gt;
&lt;body&gt;

<div id="container">
<div id="imgshow">
&lt;?php if (isset($images[0])) { ?&gt;
<a href="&lt;?php echo base_url().$dir['original'].$images[0]['original']; ?&gt;" target="_blank" id="detimglink">
<img class="imgdet" name="img_tag" src="&lt;?php echo base_url().$dir['original'].$images[0]['original']; ?&gt;" width="500"/>
</a>
&lt;?php } ?&gt;
</div>

<div id="imglist">
&lt;form enctype="multipart/form-data" id="fupload" method="post" action="&lt;?php echo site_url('image/'); ?&gt;"&gt;
&lt;input name="userfile" type="file" size="20"/&gt;
&lt;input type="submit" name="btn_upload" value="Upload ↑" class="btnupload"/&gt;
&lt;?php if (isset ($error)) { ?&gt;
<div class="error">&lt;?php echo $error; ?&gt;</div>
&lt;?php } ?&gt;
&lt;/form&gt;

<div class="clear"></div>

<div class="imgfor">
&lt;!-- Looping Array Image --&gt;
&lt;?php foreach($images as $key => $img) { ?&gt;
<div class="imgbox">
<div>
<a href="[removed]">
<img class="thumb" name="thumb" id="thumb_&lt;?php echo $key; ?&gt;" src="&lt;?php echo base_url().$dir['thumb'].$img['thumb']; ?&gt;"/>
</a>
</div>
<div class="dadel">
<a class="adel" href="&lt;?php echo site_url('image/delete/'.$img['original']); ?&gt;">
delete
</a>
</div>
</div>
&lt;?php } ?&gt;
<div class="clear"></div>
</div>
<div class="clear"></div>

<div class="bottom">
&lt;?php echo $total; ?&gt; Image(s)
</div>

<div class="bottom">
&lt;?php echo $this->pagination->create_links(); ?&gt;
</div>
</div>

<div class="clear"></div>

</div> &lt;!-- end div container --&gt;
my uploaded image folder location assets/uploads/original and assets/uploads/original
but image not display, plz any one help me.




Theme © iAndrew 2016 - Forum software by © MyBB