Jump to content

code to display images from directory not working


sid0972

Recommended Posts

i have a script to allow each member to store images in a folder named after him, so that they are exclusive to that particular member only.

 

Now when i try to retrieve it, i get error.

any ideas what might be wrong here??

 

 

<?php
session_start();
$pictures = glob("./uploads/".$_SESSION['valid_user']."/");
$no_pictures = count($pictures);

for( $i = 0; $i <= $no_pictures; $i++)
{
echo "<img src=\"".$pictures[$i]."\" />\n";
}
?>

 

thanks

Edited by sid0972
Link to comment
Share on other sites

This is the error

PHP Notice:  Undefined index: valid_user in /var/www/work/fns/display_images.php on line 3
<img src="./uploads/" />
PHP Notice:  Undefined offset: 1 in /var/www/work/fns/display_images.php on line 7
<img src="" />

 

i think its not accepting the session variable.

and i'll try hardcoding the username this time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.