From: Martin Stannard Date: 2004-05-19T09:21:58+09:00 Subject: Re: writable > On Wed, 2004-05-19 at 06:18, paul vudmaska wrote: >> Martin Stannard wrote in message >> news:<1084887383.14209.10.camel@beyond>... > > Hi Paul, > > I just set up the directory beforehand manually - the chown is just > typed on the command line. Do you have to change permissions from within > your script? > > Try rootr.net for hosting. > > gotta run, > > Martin > > Hi, Just found a problem with that file uploading code I posted earlier. It works when the uploaded file is passed as a Tempfile object but sometimes the uploaded file is passed as a StringIO object. This seems to be dependent on the size of the file but I haven't dug into the cgi code to confirm this. Anyway the upshot of this is that I've changed my code to the following: url = @cgi['url'] # TODO: add appropriate type checking here original_filename = url.original_filename path = "../tutorials/gfx/" + original_filename if url.kind_of?(Tempfile) local_file = url.local_path FileUtils.cp(local_file.untaint, path.untaint) else # assume it's a StringIO File.open(path.untaint, "w") { |f| f << url.read } end regards, Martin