有没有办法仅使用 Javascript 返回文件夹中所有图像文件名的列表?
我有一个保管箱帐户。我将一堆图像放在公共文件夹中。我想使用 Shadowbox 显示图像。
现在,我正在手动将文件名输入到此 html 文件中。当我将新图像拖到图像文件夹中时,有没有办法动态更新图库?
如果可能的话我更喜欢javascript。如果无法使用 javascript,是否有其他建议使用 Shadowbox 自动显示存储在 Dropbox 上的图像库?
我知道 Dropbox 有自己的画廊功能,但我想使用我自己的无品牌画廊功能。感谢您的帮助!
I have a dropbox account. I put a bunch of images in a public folder. I'd like to display the images using shadowbox.
Right now, I'm manually entering the filenames into this html file. Is there a way to dynamically update the gallery when I drag new images into the images folder?
I'd prefer javascript if it's possible. If it's not possible with javascript, any other suggestions to use shadowbox to automatically show a gallery of images stored on dropbox?
I know dropbox has their own gallery feature, but I'd like to use my own that's unbranded. Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先是坏消息...
出于安全原因,Javascript 无法读取服务器上的远程目录。您必须改用服务器端语言。
最后好消息...
似乎有一个 PHP 脚本可以访问您的 Dropbox 帐户,并将文件名返回到 Javascript:http://forums.dropbox.com/topic.php?id=15660 - 可以在 http://2boandco.com/demo-php-dropbox-gallery
Bad News First...
Javascript cannot read remote directories on the server, for security reasons. You'll have to use a server-side language instead.
Good News Last...
There appears to be a PHP Script that can access your dropbox account, and return the filenames to Javascript: http://forums.dropbox.com/topic.php?id=15660 - a demo can be viewed online at http://2boandco.com/demo-php-dropbox-gallery
您唯一可以可能做的就是连续命名文件(1.jpg、2.jpg),逐一获取它们的 HEAD,然后在收到 404 时停止。
The only think you could possibly do is name the files contiguously (1.jpg, 2.jpg), get the HEAD of them one by one, and then stop when you get a 404.
我最终创建了一个 python 脚本,它输出使用 Shadowbox 所需的 html。
我只需要一个名为“shadowbox”的文件夹,其中包含 Shadowbox 文件,一个名为“Full”的文件夹,包含实际图像,以及一个名为“Thumbs”的文件夹,其中包含与完整图像同名的缩略图。然后脚本将自动创建一个名为“gallery.html”的文件。
这是一个示例.. http://dl.dropbox.com/u/154234 /Images/gallery.html
这是一个 Python 脚本,供有兴趣使用它的任何人使用。我只是一个新手程序员,因此任何有关如何使代码更优雅的建议将不胜感激。谢谢!
http://dl.dropbox.com/u/154234/Images/update。 py
I ended up creating a python script that outputs the html I need to work with Shadowbox.
I just need to have a folder called "shadowbox" with the shadowbox files in it, a folder called "Full" with the actual images, and a folder called "Thumbs" with thumbnails that have the same name as the full image. Then the script will automatically create a file called "gallery.html".
Here's a sample.. http://dl.dropbox.com/u/154234/Images/gallery.html
Here's the python script for anyone interested in using it. I'm just a novice programmer, so any suggestions on how to make the code more elegant would be appreciated. Thanks!
http://dl.dropbox.com/u/154234/Images/update.py
每当将新图像(或事实上的任何其他文件)添加到某个 dropbox 文件夹(在客户端、操作系统内)时,请使用一个后台脚本来更新 content.json 文件结构,例如
:系统更改通知挂钩,例如 FSEvents、inotify 等。
然后在您的 Web 应用程序中,对位于 Dropbox 内的 content.json 执行一些 ajax 调用,并简单地迭代 json 数组以获取文件名。
优点:
Whenever a new image (or any other files as a matter of fact) is added to some dropbox folder (on the client side, within the OS), have a background script that would update a content.json file structure such as:
Using file system change notification hooks such as FSEvents, inotify, etc.
And then within your web app, perform some ajax call on the content.json located within your dropbox, and simply iterate the json array to get the file names.
Benefits: