[ic] File upload values not preserved in Session

Ed Criscuolo ed at chessie.com
Wed Jan 18 01:10:05 EST 2006


I've been having a lot of problems with file uploads.  My application
requires
uploading multiple image files.  I want to upload them all, one at a
time,
and not write any of them to files until after they're all uploaded.

What I've found is that the "file" values become corrupted before I can
write
them out to files.  If I only upload one file and save it right away, it
works fine. If, however, I try to upload a second file befor saving the
first 
one the second one is fine but the first one is corrupted.  It saves
successfully,
but produces a zero length file.

I also found that the "test=length" attribute of the "value-extended"
tag
incorrectly returns the length of the FILENAME instead of the length of
the file! 

The second problem's just an annoyance, but the first one's a killer.
Can anybody help?

Here's some example code that demonstrates the problems: 

upload.html
-----------
<html>
  <head>
    <title>Image Upload</title>
  </head>
 
  <body>
 
    <form method=post action="[process]" ENCTYPE="multipart/form-data">
      <input type=hidden name=mv_todo          value=return>
      <input type=hidden name=mv_nextpage      value=upload2>
 
      <input type="file" name="file_var">
      <input type=submit name=submit value="Upload">
    </form>
 
  </body>
</html>           


upload2.html
------------
<html>
  <head>
    <title>Second Image Upload</title>
  </head>
 
  <body>
 
    <p>
      File 1 name = [value-extended name="file_var"]
    </p>
    <p>
      File 1 size = [value-extended name="file_var" test=length]
    </p>
 
 
    <form method=post action="[process]" ENCTYPE="multipart/form-data">
      <input type=hidden name=mv_todo          value=return>
      <input type=hidden name=mv_nextpage      value=save>
 
      <input type="file" name="file2_var">
      <input type=submit name=submit value="Upload 2nd File">
    </form>
 
  </body>
</html> 


save.html
---------
<html>
  <head>
    <title>Image Saves</title>
  </head>
 
  <body>
 
    <p>
      File 1 name = [value-extended name="file_var"]
    </p>
    <p>
      File 1 size = [value-extended name="file_var" test=length]
    </p>
    <p>
      File 1 save [value-extended name="file_var"
outfile="images/testfile.jpg" yes=succeeded no=failed]
    </p>
    <p>
      File 2 name = [value-extended name="file2_var"]
    </p>
    <p>
      File 2 size = [value-extended name="file2_var" test=length]
    </p>
    <p>
      File 2 save [value-extended name="file2_var"
outfile="images/testfile2.jpg" yes=succeeded no=failed]
    </p>
 
  </body>
</html>


More information about the interchange-users mailing list