从多个文件夹

时间:2015-12-24 15:17:45

标签: javascript jquery html html5

我需要将多个文件夹中的图像上传到html页面。 例如:

first headline
-----first folder images----

second headline
-----second folder images----

我现在拥有的是只从一个文件夹上传图像的可能性(我使用jquery)。我没有,也不需要上传按钮。只需将图像放入文件夹,刷新Html页面,图像即可。 我的问题是如何将其更改为多个?

$(document).ready(function(){
    var dir = "C:\\Pic\\test\\"; 
    var fileextension = ".jpg"; 
    var i = "1";
    $(function imageloop(){
        $('.gallary').prepend('<li><a href="#"><img id="' + i + '" alt="description" /><img id="1' + i + '" alt="description" class="preview" /></a></li>')
            if (i==11){

            }
            else{
            $("#"+i).attr('src', dir + i + fileextension );
            $("#1"+i).attr('src', dir + i + fileextension );
            i++;
                imageloop();
            };
    });   
});

<div>
   <ul class="gallary"></ul>
</div>

2 个答案:

答案 0 :(得分:0)

我认为通过使用数组来保存目录位置可以实现这一目的,例如var dir = [“C:\ Pic \ test \”,“C:\ Pic \ test2 \”];并循环遍历它们。

答案 1 :(得分:0)

只需在该文档中包含文件即可。老实说,只是将图片放入该文件。节省你很多时间。如果你真的需要在另一个文件中的那些图片,而不是将该文件链接到你的html页面。

def ordinal()

  n = gets.chomp.to_i
  suffix = n % 10

  if suffix == 1
    return "That's the #{n}st item!"
  elsif suffix == 2
    return "That's the #{n}nd item!"
  elsif suffix == 3
    return "That's the #{n}rd item!" 
  else
    return "That's the #{n}th item!"
  end

end

老实说,我相信谷歌可以完全回答这个问题。

相关问题