且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Dropbox目录中的网站库中提取和显示图像

更新时间:2023-11-10 22:29:04

我前一段时间做过类似的事情.因此,是的,这是可能的.您可以搜索没有数据库的php库".您所需要做的就是为您的Dropbox的图片目录指定一个路径,并使其可以通过Web进行访问.

I have done a similar thing a while ago. So, yes, this is possible. You may search "php gallery without database". All you need is to specify a path to your Dropbox's images directory and make it accessible via web.

您需要了解Dropbox的工作原理吗?用两个词来说:它与Dropbox的服务器同步本地目录(在摄影师的计算机上为"C:/Dropbox/gallery/").之后,安装并使用摄影师帐户登录的Dropbox的其他所有实例都将获得"C:/Dropbox/Gallery/"的任何更改并将其应用于自己的副本(例如,"/var/www/Dropbox/gallery" ,例如在网络服务器上).

Do you need to learn how Dropbox works? In a two words: it syncs a local directory (let's say "C:/Dropbox/gallery/" at photographer's computer) with Dropbox's servers. After that, every other instance of Dropbox where installed and signed in with photographer's account will get and apply any changes of "C:/Dropbox/Gallery/" to the their own copy (let's say, "/var/www/Dropbox/gallery" e.g. on the web-server).

因此,首先,您需要在Web服务器上安装Dropbox( https://www .dropbox.com/install?os = lnx ).有问题吗如果是,则需要寻找其他方法.如果没有,您可以编写一个简单的函数/类,该函数/类将扫描所服务的Web目录(例如/var/www/Dropbox/gallery)以查找图像,并生成图像的可通过网络访问的路径.

So, first of all you need to install Dropbox on the web server (https://www.dropbox.com/install?os=lnx). Is it problem? If yes, you need to find another way. If not, you may just write a simple function/class which will scan served web dir (like /var/www/Dropbox/gallery) for images and generate a web-accessible paths to the images.

最简单的例子:

<?php
$images = glob("/var/www/Dropbox/gallery/*.*");
for ($i=0; $i<count($files)-1; $i++)
{
    $img = $images[$i];
    echo '<img src="/'.$img.'" alt="random image" />";
}
?>

此外,您可能对此感兴趣:我的PHP DropBox Gallery 1.0 Beta

Also, you maybe interested in this: My PHP DropBox Gallery 1.0 Beta