UploadSimpleForm


This form uploads a file and goes to the upload page afterwards.

(:input form method='post' enctype='multipart/form-data' :)
(:input hidden name='n' value='{$FullName}':)
(:input hidden name='action' value='postupload':)
File to upload: (:input file name='uploadfile':)
(:input submit value="$[Upload]":)
(:input end:)

File to upload:


Simon, is it possible to redirect to a specific page, after submitting the upload?

See the answer ferom Hans below. I can't find documentation about what values the name=action hidden field can have, or understanding how this hooks to the file upload mechanism, because this does work and upload files.

See Cookbook.Input

This is based on Test.UploadForm

This form does not upload a file.

(:input form method='post' 'enctype=multipart/form-data' :)
(:input hidden name='n' value='{$FullName}':)
(:input hidden name='action' value='browse':)
File to upload: (:input file name='uploadfile':)
(:input submit value="$[Upload]":)
(:input end:)

File to upload:


From Hans

The form on Test.UploadSimpleForm does upload a selected file. In order not to go to the upload page with the attachment list afterwards, you need to define your own HandleUpload? function, lets call it HandleCustomUpload?, and set

 $HandleActions['upload'] = 'HandleCustomUpload?';

you could copy HandleUpload? from scripts/upload.php, rename it to HandleCustomUpload?, and simply comment the last two lines and add a Redirect line:

 #  SDV($HandleUploadFmt,array(&$PageStartFmt,&$PageUploadFmt,&$PageEndFmt));
 #  PrintFmt?($pagename,$HandleUploadFmt);
    Redirect($pagename);

which will result in a silent upload, no success or failure reported.

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.21 MarkupToHTML begin
 3: 00.21 00.21 MarkupToHTML begin
 4: 00.22 00.22 MarkupToHTML end
 5: 00.22 00.22 MarkupToHTML begin
 6: 00.22 00.22 MarkupToHTML end
 7: 00.29 00.28 MarkupToHTML end
 8: 00.29 00.28 MarkupToHTML begin
 9: 00.30 00.29 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
10: 00.31 00.30 ReadApprovedUrls SiteAdmin.ApprovedUrls end
11: 00.31 00.30 MarkupToHTML end
12: 00.31 00.30 MarkupToHTML begin
13: 00.32 00.31 MarkupToHTML end
14: 00.32 00.31 now
Peak memory: 4,056,800 bytes