使用 PHP 和 jQuery 生成动态图库

发布于 2024-09-13 22:25:43 字数 768 浏览 2 评论 0原文

我脑子里有一个想法,我想创造一些东西,但我没有 确定最好的方法。我想提出这个想法并得到一些 在我一头扎进去之前,关于解决这个问题的明智方法的意见 方向错误!

我有一个摄影网站,其中显示了某个人的多个作品集 几个不同的摄影师。它有缩略图和大图像,并且 它们被组织成ul中的li

想法:

我想要一个只需要密码的登录,可以带您进入 页面允许您上传、重命名或删除指定的文件 目录。该目录将通过下拉列表中的选择来定义 菜单。

图片上传后,我希望将它们调整为大尺寸 图像和拇指,拇指在子目录中,并且有文件 按顺序命名。

图库页面会自动为每个文件夹创建一个图库 指定的目录。每个包含图像和缩略图的文件夹 文件夹。

我在想什么:

我正在考虑使用 PHP 或 Perl 脚本来上传和操作图像,以及 也许使用脚本进行 AJAX 文件上传和操作, 但我想尽可能多地手工编写代码。

我想在每个上传会话完成后,PHP 脚本 会在图库文件中生成 HTML,而不是每次 访问者访问页面,使其根据以下内容创建内容 目录。

我可以得到一些关于如何最好地解决这个问题的建议吗?

  • 哪些语言最适合 每一步? (我想主要使用 jQuery,因为这是我的大部分 JS)
  • 关于 方法还是顺序?
  • 要避免的事情 一起做吗?

提前致谢!

I've got an idea in my head, something I want to create, but am not
sure about the best approach. I'd like to pitch the idea and get some
opinions on a smart way to go about this before I dive headfirst in
the wrong direction!

I've got a photography website that displays multiple portfolios for a
few different photographers. It's got thumbnails and large images, and
they are organized into li in a ul.

The idea:

I'd like to have a login requiring only a password that takes you to a
page allowing you to upload, rename, or delete files in a specified
directory. The directory would be defined by a selection in a dropdown
menu.

After the images are uploaded I'd like them to be resized into a large
image and a thumb, the thumb in a sub-directory, and have the files
named sequentially.

The gallery page would automatically create one gallery per folder in
a specified directory. Each folder containing the images and a thumb
folder.

What I'm thinking:

I'm thinking PHP or Perl script for image upload and manipulation, and
maybe using a script out there for AJAX file upload and manipulation,
but I'd like to hand code as much as possible.

I imagine after each upload session is finished that a PHP script
would generate HTML into the gallery file, rather than each time a
visitor access the page having it create the content based on the
directory.

Could I get some advice on how best to approach this?

  • Which languages are best suited for
    each step? (I'd like to use mostly jQuery as that is most of my JS)
  • Any suggestions on the
    methods or sequence?
  • Things to avoid
    doing all together?

Thanks in advance!

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

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

发布评论

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

评论(1

世俗缘 2024-09-20 22:25:43

您所需要的只是一个好的文件上传器、基于 jquery 的图库插件以及 php 函数“file_put_contents”的一些帮助。
这里的过程是在成功上传之后,您的脚本应该从所需的文件夹中生成正确的图像列表。
示例:

$theGallery ="<ul class='gallery'>";
$dir = "dir_of/images";
$good_ext = array(".jpg",".gif");


if ($handle = opendir($dir)) {
     while (false!== ($file = readdir($handle))) {
     $ext = strrchr($file,".");
          if(in_array($ext,$good_ext))
          {
          //do something with file
          $theGallery .="<li><img src='".$file."'></li>";
          }
    }
closedir($handle);
}
else
{
$theGallery .="<li>Directory does not exist!</li>";
}
$theGallery .= "</ul>";

然后添加一些 html 和 javascript 代码,例如:

 $(document).ready(function(){
      $('ul.gallery').toGallery();
 });

一些 jquery 插件很容易实现,就像这样。感谢选择者。

脚本的最后部分是将动态生成的 html 代码放入文件中。
所以我们将使用“file_put_contents”或任何具有相同功能的函数。

all you need is a good file uploader, jquery based gallery plug in and some help of a php function "file_put_contents".
the process here is after a successful upload your script should generate a proper ul li list of images from the desired folder.
example:

$theGallery ="<ul class='gallery'>";
$dir = "dir_of/images";
$good_ext = array(".jpg",".gif");


if ($handle = opendir($dir)) {
     while (false!== ($file = readdir($handle))) {
     $ext = strrchr($file,".");
          if(in_array($ext,$good_ext))
          {
          //do something with file
          $theGallery .="<li><img src='".$file."'></li>";
          }
    }
closedir($handle);
}
else
{
$theGallery .="<li>Directory does not exist!</li>";
}
$theGallery .= "</ul>";

and then add some html and javascript code like:

 $(document).ready(function(){
      $('ul.gallery').toGallery();
 });

some jquery plug ins are easy to implement just like that. thanks to the selectors.

the final part of the script if to put your dynamically generated html codes to a file.
so we gonna use the 'file_put_contents' or any functions that does do the same.

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