Hi, folks
I wroted the codes below.
I have the trouble with the line start from "Dir.chdir".
When I run this code, the FTP of photos is successfuly done.
But, the display of browser is white out.
When I comment out the line start from "Dir.chdir",
the trouble doesn''t happen.
Is there anything wrong with my usage of "Dir.chdir"?
def ftp_photo
$basedir = "/home/yosuke/public_html/myalbum/albums/"
$tempdir = "/home/yosuke/public_html/testing/tempPhoto/"
targetdir = params[:targetdir]
@targetdir = params[:targetdir]
fhostname = ''hogefpt.co.jp''
fusername = ''hoge''
fuserpass = ''hogehoge''
fbasedir = ''/hogehoge/''
targetdirpath = $tempdir + targetdir
Dir.chdir targetdirpath
begin
ftp = Net::FTP.open(fhostname,fusername,fuserpass)
@messageftpconnect = "connected"
rescue
@messageftpconnect = "failed"
end
ftp.chdir(fbasedir)
begin
ftp.mkdir(targetdir)
@messageftpmkdir = "the directory was created"
rescue
@messageftpmkdir = "the directory already exists"
end
ftp.chdir(targetdir)
Dir::glob("./*.jpg").each {|f|
ftp.put(f)
}
ftp.close
FileUtils.rm_rf(targetdirpath)
end
ftp_photo.rhtml
start ???<br />
<%= @messageftpconnect %><br />
<%= @messageftpmkdir %><br />
layout file
<html>
<head>
<title>my tool</title>
<%= stylesheet_link_tag "mytool", :media => "all"
%>
<meta http-equiv="content-type" content="Mime-Type;
charset=UTF-8">
</head>
<body>
<div id="banner">
my tools
</div>
<div id="column">
<div id="side">
<a href="http://www">home</a><br />
</div>
<div id="main">
<% if @flash[:notice] -%>
<div id="notice"><%= @flash[:notice] %></div>
<% end %>
<%= @content_for_layout %>
</div>
</div>
</body>
</html>
#Sorry japanese readers,
#I sent the same mail to the ML for japanese rails users
-----
Yosuke Suzuki from Japan