javascript - image retrieval from directory and session variable issues - php -


i have problem when retrieving images directory on server, main sequence is: in page (multiupload.php) added input, allowed image previewed , when user submitted, new directory session id created, images stored in unique directory , page directed (drag.php). newly loaded page has canvas different divs controls filters attached canvas. problem lies retrieving image specified s_id directory name 1 page other.

q: retrieving session variables properly? or using them appropriately?

this necassary snippets multiupload.php's upload script.

<?php   $dir_id = session_id(md5(uniqid()));   session_start($dir_id);   $path = "uploads/";   $dir = $path.$dir_id;   $path = $path.$dir_id."/";   if (file_exists($dir)) {     system('/bin/rm -rf ' . escapeshellarg($dir));   } else {     mkdir($path);     chmod($path, 0722);     }   $_session["id"] = $dir_id;   $_session["directory"] = "/" . $dir;   $_session["path_name"] = $path; ?> 

i define directory, whole path , id directory. retrieve id in next page, it's not doing correctly.

and retrieval code drag.php

$realpath = 'uploads/'. echo $_session['id'];  $handle = opendir(dirname(realpath(__file__)).$realpath; while($file = readdir($handle)){     if($file !== '.' && $file !== '..'){         echo '<img src="uploads/'.$file.'" border="0" />';     } } 

my end result images drawn on page. them drawn anywhere aslong they're visible.

if question isn't clear, feel free edit or comment should change. if need more code or information, please let me know.

please modify code code:

<?php   $dir=$_session['id'];   $realpath = '/uploads/'.$dir;   $handle = opendir(dirname(realpath(__file__)).$realpath);     while($file = readdir($handle)){       if($file !== '.' && $file !== '..'){         echo '<img src="'.$realpath.'/'.$file.'" border="0" width="200" />';     }   } ?> 

i have use code o/p this:

enter image description here


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -