|
From: Brad P. <br...@ro...> - 2002-09-24 23:36:11
|
Hi all... I was playing around some more and I noticed something
interesting. I have dug into it a little, but thought I would post here
and see what came of it.
I made a code object that uses basefile to upload files. (I have been
recreating some of the things on the bacfug site, hence the code object,
in hopes that my exploring will produce some documentation on how to
create a simple site with Modus) The code object has a three fields:
title, file, and description. I wanted to change where the file was
uploaded, so I took advantage of the setDirectory method. Here is the
snippet that does this:
// create an initizlie a code object
code = createObject("component","bacfug.contentobjects.code").init();
// if the form was POSTed process it
if (isDefined("form.fieldnames")) {
// set the id
// i need to explore this more, but it
// seems to work in place of a isNew field
code.setID(form.id);
// set the directory to upload to
code.getField("file").setDirectory("#expandPath("/bacfug/code/")#");
// set the field values based on the form
code.setFieldValues(argumentCollection=form);
// if there are no errors, commit it to the database
if(NOT code.hasErrors()){
// send it to the database
code.store();
// reinitialize
code.init();
}
}
This works fine. However, if I call setFieldValues before setDirectory,
the file is uploaded into the default directory ("/"). This is almost
counterintuitive to me. I thought perhaps the setValue calls in
setFieldValues might overwrite something. Looking into these two
methods, I couldn't find anything that would cause one to overwrite the
other. That makes me think that I should be able to call these in either
order and get the desired outcome.
Any thoughs?
Brad
|