/
File upload processing place relocation

File upload processing place relocation

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/d5ca0f1c65038a40#

There can be a lot of different field types and form controls on the
form. Some of fields have scalar data in them, like text or numbers, but
some don't, like upload fields.

To deal with data from forms In-Portal has formatter classes. These classes
are used to convert data from database to human readable form and backward.
For example dates are stored as timestamps in database, however they are
displayed according to regional setting date format to user.

Let's take user registration form for example, that contains avatar upload
field too.

When user fills in some data and hits "Register" button, then all data is
sent to the server for validation. When validation succeeds, then record is
created in database. When validation fails, then user is returned back to a
form with problematic fields highlighted.

All seems since until upload fields comes to the stage. What happens with
them you could ask? I guess the answer is that they are processed and
uploaded filename will be stored in a form field.

Question is: where they are uploaded exactly, while the form has errors on
it.
Answer is: into target upload folder, e.g. /system/images/user_avatars/ for
example.

They are uploaded an it's good. But when user closes the registration form,
then uploaded file will stay in that folder forever and only waste hosting
space.

This all happens, because formatters are the ones, who upload a file right
away (even when there are an errors on the form).

Here is what I propose to do (but I don't have enough technical info to
implement it):

   - let formatters upload, but only to /system/tmp/ folder
   - form validation shouldn't be triggering any upload process
   - methods: kDBItem::Create and kDBItem::Update will move file from
   /system/tmp/ to a target upload folder

Now flash uploader comes in. A file is automatically uploaded to
/system/tmp/ after it has been selected from browse dialog. That's good. But
on first validation attempt it again moves file to target upload folder,
while it shouldn't do that.

--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com