[ic] File upload

Marco Mescoli interchange-users@icdevgroup.org
Wed Oct 2 07:44:03 2002


----- Original Message -----
From: "Kevin Walsh" <kevin@cursor.biz>
To: <interchange-users@icdevgroup.org>
Sent: Wednesday, October 02, 2002 10:16 AM
Subject: RE: [ic] File upload

Well i have tested the code and very thanks upload OK.
I add the tag  [value-extended name=uploaded_file file_contents=1] to
display file content.
But two problem:
1) [if scratch result eq 'Success'] do not pass even if [scratch result] is
really equal "Success".
I try some other type of "if compare" with the same result.
2) If in <input type="file ... > i put a non existent file name [scratch
result] is equal "Success". May be a problem in [value-extended
name=uploaded_file test=isfile] ?

----------------------- uploadedit.html ---------------------------------
<head>
<title> Input upload file name </title>
</head>
<body>
  <form action="[process-target]" method="POST"
enctype="multipart/form-data">
    <input type="hidden" name="mv_session_id" value="[data session id]">
    <input type="hidden" name="mv_todo" value="return">
    <input type="hidden" name="mv_nextpage" value="@@MV_PAGE@@">
    File to upload:
    <input type="file" name="uploaded_file">
    <br><br>
    <input type="submit" name="mv_check" value="Send">
  </form>

  [set Send]
    mv_nextpage=anagraf/uploadfile
  [/set]
</body>
</html>

----------------------- uploadfile.html ---------------------------------
<head>
<title> Do uploading </title>
</head>
<body>
  [set outfilename]tmp/test_file[/set]
  [if type=explicit compare="[value-extended name=uploaded_file
test=isfile]"]
  [then]
    [tmp result]
      [value-extended
        yes="Success"
        no="Failed"
        ascii=0
        name=uploaded_file
        outfile="[scratch outfilename]"
    ]
    [/tmp]
    [if scratch result] <!-- BEWARE NOT CORRECT -->
      [tmp result]File upload succeeded.[/tmp]
      File contents:<br>
      [value-extended name=uploaded_file file_contents=1]
    [else]
      [tmp result]File upload failed.[/tmp]
    [/else]
    [/if]
  [/then]
  [else]
    [tmp result]No file upload was specified.[/tmp]
  [/else]
  [/if]
  <br><br>
  [scratch result]
</body>
</html>
-------------------------------------------------------------------