View Single Post
Old Jun 5th, 2006, 8:01 AM   #1
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
using input names to find and display files.

<?php
/* if the "submit" variable does not exist, the form has not been submitted - display initial page */
if (!isset($_POST['submit'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  <input name="File" size="15">
  <input type="submit" name="submit" value="Go">
</form>

<?php
}
else {
// open file
$fh = fopen($File, 'r') or die('Could not open file!');
// read file contents
$data = fread($fh, filesize($File)) or die('Could not read from file!');
// close file
fclose($fh);

// get detail
// print file contents
echo "<img src=\"$File\">";

}
?>

the concept is simple: gets an input in the form then outputs the corresponding picture of the same name.

Doesn't work, I have no idea why, plus the fact that I'm having difficulty testing it.. (slow net connection = 30++ second waits between testing).
tumbleTetris is offline   Reply With Quote