doucong1853 2011-10-23 19:42
浏览 54
已采纳

使用PHP在另一个网页上显示文件/图像(例如Cloudapp或Droplr)

I'm looking for a way to display a file or image on another page like used in Cloudapp or Droplr. I ask, because I would like to display advertisements on those pages for where the user views their files. To the best of my knowledge this can be done with PHP.

I have a system step and developed already for the user to upload their file(s) to a folder on my server. All I need now is to display ads on the file pages...

  • 写回答

2条回答 默认 最新

  • dqzpt40064 2011-10-23 20:29
    关注

    Here is a basic framework for a file that displays an image and an advert:

    <?php
    
      // Path to the directory that holds the images
      $imageDir = 'images/';
    
      // Make sure an image was requested
      if (!isset($_GET['image'])) {
        exit('No image requested to display');
      }
    
      // Full path to image
      $imagePath = $imageDir.$_GET['image'];
    
      // Make sure the image exists
      if (!is_file($imagePath)) {
        exit("Image doesn't exist!");
      }
    
    ?>
    <html>
    
      <head>
        <title><?php echo $imagePath; ?></title>
      </head>
    
      <body>
        <div>
          <!-- HTML for advert goes here -->
          <div>Buy Stuff! It's great for wasting your money on!</div>
        </div>
        <div>
          <!-- Display the image -->
          <img src="<?php echo $imagePath; ?>" alt="<?php echo $imagePath; ?>" />
        </div>
      </body>
    
    </html>
    

    This is missing many pieces, but then so is you description of what you want...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?