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

发布于 2024-12-11 21:34:27 字数 172 浏览 0 评论 0原文

我正在寻找一种在另一个页面上显示文件或图像的方法,就像在 Cloudapp 或 Droplr 中使用的那样。我问,因为我想在用户查看文件的那些页面上显示广告。据我所知,这可以使用 PHP 来完成。

我已经开发了一个系统步骤,供用户将其文件上传到我的服务器上的文件夹。我现在需要的只是在文件页面上显示广告......

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新人笑 2024-12-18 21:34:27

这是显示图像和广告的文件的基本框架:

<?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>

这缺少很多部分,但是您对想要的内容的描述也是如此......

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...

紫罗兰の梦幻 2024-12-18 21:34:27

输出有什么问题

<img src="http://theotherserver/path/to/image" />

简单地从脚本中 。当然,您可以让 PHP 获取图像并为您的用户代理它,然后您的带宽费用就会增加一倍(点击一次获取图像 droplr-> 服务器,然后再点击一次从服务器发送图像-> 服务器)。用户)。

What's wrong with simply outputting

<img src="http://theotherserver/path/to/image" />

from your script. You can certainly have PHP fetch the image and proxy it for your user, then then you're doubling your bandwidth bill (1 hit to fetch the image droplr->server, and then another hit to send the image from server->user).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文