Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to view posting on the web page?

Status
Not open for further replies.

newlearner2005

Programmer
May 9, 2005
32
US
Hello everybody

I used a PHP coding program from internet to upload files to the server. It worked well . I saw the statement "The file was uploaded sucessfully !" on my webpage. But how to post that file on the web page (as a link )so that everybody from client computer can click on that to opne to read and save it to their computers.
Could anybody help me ? I have hard time doing that because I am new learner about Apache, PHP and MySQL.
Thank you very much in advance. I really appreciate.

newlearner2005
 
u have to use the directory and file functions provided in php...

Known is handfull, Unknown is worldfull
 
The function below prints 'dynamic' links to directories present below the "gallery" directory
Code:
<?php function getBreadCrumbs () {
	$dh  = opendir("./gallery");
	while (false !== ($filename = readdir($dh))) {
	  	$files[] = $filename;
	}
	@sort($files);
	foreach ($files as $file) {
	  if (($file != ".") && ($file != "..")) {
  	    echo "<li><a href='[URL unfurl="true"]http://www.mysite.com/gallery.php?dir=".$file."'[/URL] class='gallery'>".$file."</a></li>";
  	  }
	}
	return $files;
 }
php getBreadCrumbs();  ?>
The code below prints out the images as thumbnails in a subdirectory, and the first of the images full size. Instead of image tags, just build up <a href= ...>link</a>
Code:
<?php
$site="[URL unfurl="true"]http://www.mysite.com/pandm/";[/URL]
  if (isset($HTTP_GET_VARS['dir'])) {
	$dh  = opendir("./gallery/".$HTTP_GET_VARS['dir']."/thumbs/");
	while (false !== ($filename = readdir($dh))) {
	  	$files[] = $filename;
	}
	@sort($files);
    if (count($files)==2) {
	    echo "<h2>No pictures in the &quot;".$HTTP_GET_VARS['dir']. "&quot; gallery at present, please check back later</h2>";
    } else {
       $loop=0;
       if (!(isset($HTTP_GET_VARS['showfile']))) {
          $file_to_show=$files[2];
       } else {
          $file_to_show=$HTTP_GET_VARS['showfile'];
       }
       list($title_to_show, $crap)=split ("\.", $file_to_show);
       $picture="<img src='".$site."gallery/".$HTTP_GET_VARS['dir']."/".$file_to_show."' alt='".
          $title_to_show. "' title='".$title_to_show."' />\n<br />\n  <h2>".$title_to_show."</h2>\n";
       echo "\n<table border=".'"'."0".'"'.">\n  <tr>";
       foreach ($files as $file) {
    	  if (($file != ".") && ($file != "..") && ($file!="footer.txt")) {
    	    list($title, $crap)=split ("\.", $file);
    	    $loop++;
            echo "    <td><a href=".'"'.$site."gallery.php?dir=".$HTTP_GET_VARS['dir']."&amp;showfile=".$file.'"'.
                  "><img src='[URL unfurl="true"]http://www.mysite.com/gallery/".[/URL] $HTTP_GET_VARS['dir']."/thumbs/".$file."'\n alt='".
                 $title."'\n title='".$title."' width=".'"'."100".'"'." height=".'"'."76".'"'." /></a>\n</td>\n" ;
            if ($loop%5==0) {
              echo "\n  </tr>\n  <tr>\n";
            }
          }
       }
       echo "</tr>\n</table>";
       echo $picture;
       if (file_exists("gallery/".$HTTP_GET_VARS['dir']."/footer.php")) {
         include "gallery/".$HTTP_GET_VARS['dir']."/footer.php";
       }
    }
  }
?>

HTH
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top