1. List all files in the current directory
<%
@files = Dir.entries("/var/www/bookstore/public/images")
for file in @files
%>
<%= file %>
<%
end
%>
@files = Dir.entries("/var/www/bookstore/public/images")
for file in @files
%>
<%= file %>
<%
end
%>
2. List all files in the current directory and strip out . and ..
<%
@files = Dir.entries("/var/www/bookstore/public/images")
for file in @files
if file != "." && file != ".."
%>
<%= file %>
<%
end
end
%>
@files = Dir.entries("/var/www/bookstore/public/images")
for file in @files
if file != "." && file != ".."
%>
<%= file %>
<%
end
end
%>
If you find this useful, would you like to buy me a drink? No matter more or less, it will be an encouragement for me to go further. Thanks in advance!! =)
No comments:
Post a Comment