[ic] ENCTYPE being ignored on multi use form

Paul Jordan interchange-users@icdevgroup.org
Tue Apr 15 12:28:01 2003


Ok guys, this one is ugly. IC 4.9.7, and needs explaining.

Short version for clairvoyant: -----
I have a form that has multiple <input type=submit name=mv_click... that
resort to a [set] altering the mv_nextpage and such... It seems that when
these methods are used, having enctype="multipart/form-data" is ignored, and
the default text/plain is used instead. Prohibiting me from uploading
anything but .txt files.
-----------------------------------

OK, I have a pseudo ADMIN in the works. In part, it has a built in webmail
section. Everything is great, and on the "reply" page, I have a great UI
that lets the type a message <message>, insert recipients <recipients>, and
attach files <attach>.

At first I was doing these with two separate forms, one for the email
message (send) and one for the attaching of files (the names of the files
get loaded into a scratch). This was working great and I could upload
anything.

The problem arose that if a user was typing in a message, then after a
minute decided to "attach a file, the second <attach> form would be
submitted (to upload file to temp dir), an not the <message> form, thus
losing the half written message!

I saw no hack for that problem, getting the values of an unrelated form to
save, as well as the values for the form being submitted. So, I am trying to
combine the form, into one form, so any "undulations" by the user, will save
all the data, until they are done.

The simplified code is below. Much is left out for size purposes. However I
have narrowed down the problem. With the below code, everything works great,
except I can now only upload .txt files. I used to be able to upload
anything. I think because of my mv_clicks that alter the path of the form
variables, somehow my enctype is getting ignored, so on my next page, the
value_extended test=isfile is failing when a .jpg .foo is uploaded.


<form ACTION="[process-target]" METHOD="POST" name=crm
enctype="multipart/form-data">
<INPUT type=hidden name="mv_todo" value="return">
<input type=hidden name=mv_session_id value="[data session id]">

[set Send]
    mv_todo=submit
    mv_order_profile=message_profile
    mv_failpage=@@MV_PAGE@@
    mv_successpage=cg/client
[/set]
...
<input type="submit" name=mv_click value="Send">  #sending of email
...
<input type="file" name="uploaded_file">
...
<input type="submit" name=mv_check onClick="window.open('[area
cg/do/upload]','Uploading','menubar=no,width=50,height=50,scrollbars=no,stat
us=no'); window.open('[area
cg/do/waiting]','WaitWin','menubar=no,width=300,height=100,scrollbars=no,sta
tus=no');" target="Uploading" value="Add file">

[set Add file]
   mv_todo=submit
   mv_nextpage=cg/do/upload
[/set]

</form>

OK OK, the last submit needs explaining. I can tell you that it works,
because in the -separate- form method, it works great. The last UGLY submit
button launches two small popups. They are designed to avoid a blank screen
if a users uploads a 600K file and takes 25, 20 seconds. One popup is very
small, and has the code for [value-extended..] uploading, which "hangs"
until file is uploaded to temp directory. The second window is a small
blinking: ! Please wait while your file is being uploaded! window that
retains focus. They are all automatically closed when the file is done
uploading.

I need to point out. #1 this is a private access controlled system, so if
you see barring security issues, please know they are either taken care of,
or being taken care of, so no need to point them out. #2 It does require the
use of Javascript... it is an ADMIN, and has qualifications.

Any help would be awesome. Either how to save the values of an unrelated
form, or how to get the enctype to be recognized when using mv_clicks.

Thanks

Paul