Trouble with Dir.chdir

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 e$B#F#T#Pe(B

<%= @messageftpconnect %>

<%= @messageftpmkdir %>

layout file

my tool <%= stylesheet_link_tag "mytool", :media => "all" %>
my tools
<% if @flash[:notice] -%>
<%= @flash[:notice] %>
<% end %> <%= @content_for_layout %>

#Sorry japanese readers,
#I sent the same mail to the ML for japanese rails users


Yosuke Suzuki from Japan