dispector
08-09-2005, 11:11 AM
i dont know if this should go in php or html..but whatever
heres the deal..
i have a form where users input their name and can upload a pic from their HD to the server. ok, good, got that part done
-----------------------
the trouble im having is displaying that stuff. I need to set it up so it looks like this
name
image
OR
nameimage
whichever is easier to do acording to the following....problems you could say
-----------------------
the user inputs their name, which is then stored into a text file. they are then given an option to upload an image. if they dont, a default one is used.
so somehow using tables and rows maybe, i need to display the images with their corrisponding names. heres the php for the output
$filename = "os/thenames.txt";
$handle = fopen($filename, "r"); //opens file
$contents = fread($handle, filesize($filename)); //stores file content in $contents
fclose($handle); //closes file
print "$contents"; //prints content
$dirName = "os"; //opens directory
$dp = opendir($dirName);
chdir($dirName);
while ($currentFile !== false){
$currentFile = readdir($dp);
$theFiles[] = $currentFile;
}
$imageFiles = preg_grep("/jpg$/", $theFiles); //grabs jpg files
foreach ($imageFiles as $currentFile){ //prints images
print "<img src='http://www.domain.com/os/$currentFile' width='150' border='1'>";
}
if i dont do anything to the formating, it displays like this:
namenamename
imageimageimage
now does anyone have any ideas how i can change this? please ask any questions if you dont understand, im usually not very good at explaining things...but ive been working on this since 3am and its now 5 with no results
this whole script in general has taken me about 8 hours...(its the first big script ive writtin and i suck at php 9not to mention im anal about every detail)) any help....id be eternally grateful
heres the deal..
i have a form where users input their name and can upload a pic from their HD to the server. ok, good, got that part done
-----------------------
the trouble im having is displaying that stuff. I need to set it up so it looks like this
name
image
OR
nameimage
whichever is easier to do acording to the following....problems you could say
-----------------------
the user inputs their name, which is then stored into a text file. they are then given an option to upload an image. if they dont, a default one is used.
so somehow using tables and rows maybe, i need to display the images with their corrisponding names. heres the php for the output
$filename = "os/thenames.txt";
$handle = fopen($filename, "r"); //opens file
$contents = fread($handle, filesize($filename)); //stores file content in $contents
fclose($handle); //closes file
print "$contents"; //prints content
$dirName = "os"; //opens directory
$dp = opendir($dirName);
chdir($dirName);
while ($currentFile !== false){
$currentFile = readdir($dp);
$theFiles[] = $currentFile;
}
$imageFiles = preg_grep("/jpg$/", $theFiles); //grabs jpg files
foreach ($imageFiles as $currentFile){ //prints images
print "<img src='http://www.domain.com/os/$currentFile' width='150' border='1'>";
}
if i dont do anything to the formating, it displays like this:
namenamename
imageimageimage
now does anyone have any ideas how i can change this? please ask any questions if you dont understand, im usually not very good at explaining things...but ive been working on this since 3am and its now 5 with no results
this whole script in general has taken me about 8 hours...(its the first big script ive writtin and i suck at php 9not to mention im anal about every detail)) any help....id be eternally grateful