![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: May 2006
Posts: 39
Rep Power: 0
![]() |
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). |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
Wouldn't this imply that the user would have to know the filename ahead of time? Why not just list an image directory with hyperlinks?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 |
|
Programmer
Join Date: May 2006
Posts: 39
Rep Power: 0
![]() |
oh, yes I know that.
I'm doing this as sort of practice, its not supposed to have any practical purposes ![]() |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Oh, in that case... You are trying to open a file referenced in code as $File that is never defined. Try this, right above where you are trying to open the file...
$File = $_POST['File'];
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Programmer
Join Date: May 2006
Posts: 39
Rep Power: 0
![]() |
thanks, that done the trick
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|