问题描述
我脑子里有了一个主意,我想创建一个主意,但不是确定最好的方法.我想提出这个想法并得到一些在我深入研究之前,以明智的方式解决此问题错误的方向!
I've got an idea in my head, something I want to create, but am notsure about the best approach. I'd like to pitch the idea and get someopinions on a smart way to go about this before I dive headfirst inthe wrong direction!
我有一个摄影网站,其中显示了一个几个不同的摄影师.它有缩略图和大图像,并且它们被组织在ul
中的li
中.
I've got a photography website that displays multiple portfolios for afew different photographers. It's got thumbnails and large images, andthey are organized into li
in a ul
.
想法:
我想登录时只需要一个密码即可将您带到该页面允许您上载,重命名或删除指定文件中的文件目录.该目录将通过下拉菜单中的选择定义菜单.
I'd like to have a login requiring only a password that takes you to apage allowing you to upload, rename, or delete files in a specifieddirectory. The directory would be defined by a selection in a dropdownmenu.
上传图片后,我希望将它们调整为大尺寸图像和一个大拇指,这个大拇指在一个子目录中,并具有文件顺序命名.
After the images are uploaded I'd like them to be resized into a largeimage and a thumb, the thumb in a sub-directory, and have the filesnamed sequentially.
图库页面将自动为文件夹中的每个文件夹创建一个图库指定的目录.每个包含图片和缩略图的文件夹文件夹.
The gallery page would automatically create one gallery per folder ina specified directory. Each folder containing the images and a thumbfolder.
我的想法:
我正在考虑使用PHP或Perl脚本进行图像上传和操作,并且也许使用那里的脚本进行AJAX文件上传和操作,但我想尽可能地编写代码.
I'm thinking PHP or Perl script for image upload and manipulation, andmaybe using a script out there for AJAX file upload and manipulation,but I'd like to hand code as much as possible.
我想在每个上传会话完成之后,一个PHP脚本会在图库文件中生成HTML,而不是每次访问者访问其创建内容的页面,该页面基于目录.
I imagine after each upload session is finished that a PHP scriptwould generate HTML into the gallery file, rather than each time avisitor access the page having it create the content based on thedirectory.
我可以就如何最好地解决此问题获得一些建议吗?
- 哪种语言最适合每一步? (我想主要使用jQuery,因为这是我的大部分JS)
- 关于方法或顺序?
- 应避免的事情一起做吗?
- Which languages are best suited foreach step? (I'd like to use mostly jQuery as that is most of my JS)
- Any suggestions on themethods or sequence?
- Things to avoiddoing all together?
谢谢!
推荐答案
您所需要的就是一个好的文件上传器,基于jquery的图库插件以及php函数"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>";
,然后添加一些html和javascript代码,例如:
and then add some html and javascript code like:
$(document).ready(function(){
$('ul.gallery').toGallery();
});
有些jQuery插件很容易实现.多亏了选择器.
some jquery plug ins are easy to implement just like that. thanks to the selectors.
脚本的最后一部分,是否将动态生成的html代码放入文件中.因此我们将使用'file_put_contents'或执行相同操作的任何函数.
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.
这篇关于使用PHP和jQuery生成动态图像库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!