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.11 00.11 MarkupToHTML begin
 3: 00.11 00.11 MarkupToHTML begin
 4: 00.12 00.12 MarkupToHTML end
 5: 00.12 00.12 MarkupToHTML begin
 6: 00.12 00.12 MarkupToHTML end
 7: 00.18 00.17 MarkupToHTML end
 8: 00.19 00.17 MarkupToHTML begin
 9: 00.20 00.18 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
10: 00.20 00.18 ReadApprovedUrls SiteAdmin.ApprovedUrls end
11: 00.20 00.19 MarkupToHTML end
12: 00.20 00.19 MarkupToHTML begin
13: 00.21 00.19 MarkupToHTML end
14: 00.21 00.19 now
Peak memory: 3,685,040 bytes