[ic] File upload

Kevin Walsh interchange-users@icdevgroup.org
Wed Oct 2 04:17:04 2002


Marco Mescoli [m.mescoli@omnibit.nu] wrote:
> 
> I have searched in construct, in admin pages and in the mailing list archive
> without clear and simple results.
> How can i make file upload with IC tags ?
> 
Here are a couple of untested blocks of code.  Create two pages
as follows:

testpage.html:
--------------

<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@@">

    [L]File to upload[/L]:
    <input type="file" name="uploaded_file">

    <br><br>
    <input type="submit" name="mv_check" value="[L]Upload file[/L]">
</form>

[set [L]Upload file[/L]]
    mv_nextpage=testpage_upload
[/set]



testpage_upload.html
--------------------

[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="tmp/test_file"
    ][/tmp]
    [if scratch result eq 'Success']
        [tmp result][L]File upload succeeded.[/L][/tmp]
    [else]
        [tmp result][L]File upload failed.[/L][/tmp]
    [/else]
    [/if]
[/then]
[else]
    [tmp result][L]No file upload was specified.[/L][/tmp]
[/else]
[/if]
[scratch result]


The first page should present a form and allow you to specify a file
to be uploaded.  When you press the "Upload file" button, you should
be taken to the second page.

The second page should save the uploaded content to "tmp/test_file"
and show a success/failure message.

This should give you some idea of how to proceed with what you want
to do.

Good luck.

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/