PDA

View Full Version : Auto adding to a page



GoldenMerc
11-12-2009, 06:14 PM
Well i want avatars to automatically add to a page, so once they hit the directory they will automatically upload to the site in a image format. there on the same sever, how would i do this?
Ross

GoldenMerc
11-12-2009, 11:10 PM
anyone?

Yonder
12-12-2009, 12:25 AM
Explain please i dont understand what you want to achieve.

Blinger$
12-12-2009, 12:30 AM
Basically you need to get the listings of the directory, then for each image (i presume the folder will just contain images?) add a <img src="$file"> tag around it. The $file would come from the listing of the directory ;)


edit:
http://php.net/manual/en/function.readdir.php

so the code would be something like the 2nd example (i changed it a little)



<?php
if ($handle = opendir('avatar')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<img src='$file'>\n";
}
}
closedir($handle);
}
?>

GoldenMerc
12-12-2009, 12:40 AM
So im guessing the php file would be in the document with where i want the images put? then the images would be in the same folder?
Ross

Want to hide these adverts? Register an account for free!