Search
Left Quote    By failing to prepare, you are preparing to fail.
- Benjamin Franklin    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: A little help
  This user is offline  gravy
  Subject: "A little help" Posted: @ 1:05 am on Mar 18 2007   

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

Okay so I made it so that the user name is inserted into the file name when the upload takes place example: adminbfgeythdyu g.jpg

and I can open and read the images/ directory with this code:


Code:

<?
$file_path = "images/&q uot;; //dir
$with_subdirs = false; // with subdirs?
$what_file = "/$user.+\ .(gif$|jpg$|jpe g$|png$)/i" ;; // what file? (reg ex)

$pics = addfiles($file_ path,$what_file ,$with_subdirs) ;

echo implode("& lt;br>" ,$pics);

function addfiles($path, $what_file,$wit h_subdirs)
{
global $files;
$files[0] = ""; $handle = @opendir($path) ;
while ($file = @readdir ($handle)) {
if ($file != "." && $file != ".."{
if ($with_subdirs) addfiles($path. $file."/&q uot;,$what_file ,$with_subdirs) ; // subdirs
if (preg_match($wh at_file , $file)) $files[] = $path.$file; // addfile
}
}
@rewinddir ($handle);
@closedir($hand le);
unset ($files[0]);
return $files;
}

?>


But....

How do I make this into a full link that can be clicked for the full sized image page?


Photo Hosting Scripts? It's what I do....
    Viewed: 5,149 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: A little help" Posted: @ 1:17 am on Mar 18 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Create a column in your users table "image&q uot; and when the pic is uploaded, store the image name in the image column. Knowning you store images in /users/images/ create a link like this:

echo("< ;a href='http://w ww.yoursite.com /users/images/ '".$from_ db->image.& quot;'>Clic k to view image</a> ");




-bs0d | AllSyntax.com

    Viewed: 5,142 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: A little help" Posted: @ 2:45 am on Mar 19 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

I got it done man!

I had to create another table called "files&q uot; and in that table I added a column for the username and one called image. Now when an image is uploaded while logged in it goes into their row and then I can display any photos under their username.

So now all of their thumbnails are displayed on their profile page. Awesome!

Thanks for the help!




Photo Hosting Scripts? It's what I do....

    Viewed: 5,107 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank