R LINEND X'30'
UTABLE LNTBL 300
* --------------------------------------------------------------- *
* Upload a file from the client machine to a Model 204 procedure. *
* *
* Changes necessary to make this proc work at your site: *
* *
* 1. Uncomment the call to $Web_Proc_Recv. *
* 2. Substitute these two includes: *
* *
* In JANWEB Include WEB/TEMPLATE_TOP *
* In JANWEB Include WEB/TEMPLATE_BOTTOM *
* *
* with calls to your own html page "start" and "end" procs. *
* *
* --------------------------------------------------------------- *
Begin
%dt is Float Common
%i is Float
%j is Float
%rc is Float Common
%fBin is String len 3 Common
%fBinChecked is String len 7 Common
%FGName is String len 30 Common
%Format is String len 10 Common
%Method is String len 10 Common
%Password is String len 8 Common
%Prefix is String len 255 Common
%Proc is String len 255 Common
%Source is String len 255 Common
%Suffix is String len 6 Common
%Type is String len 30 Common
* Web session setup.
%dt = $Web_Date + (30 * 24 * 60 * 60)
%rc = $Web_On
%rc = $Web_Type('TEXT/HTML')
%rc = $Web_Sub('@@')
%rc = $Web_Expire(-1)
%rc = $Web_Response('PRAGMA', 'NO-CACHE')
* If form was "posted" capture the input and reset cookie.
%Method = $UpCase($Web_Hdr_Parm('METHOD'))
If %Method eq 'POST' Then
%Type = $UpCase($Web_Form_Parm('type'))
%FGName = $UpCase($Web_Form_Parm('fgname'))
%Password = $UpCase($Web_Form_Parm('password'))
%Prefix = $UpCase($Web_Form_Parm('prefix'))
%Source = $UpCase($Web_Form_Parm('source'))
%fBin = $UpCase($Web_Form_Parm('fbin'))
%rc = $Web_Set_Cookie('TYPE', %Type, %dt )
%rc = $Web_Set_Cookie('FGName', %FGName, %dt )
%rc = $Web_Set_Cookie('PREFIX', %Prefix, %dt )
%rc = $Web_Set_Cookie('SOURCE', %Source, %dt )
%rc = $Web_Set_Cookie('FBIN', %fBin, %dt )
* Else (form method is "get") see if we can populate form from cookie.
Else
%Type = $Web_Cookie_Parm('TYPE')
%FGName = $Web_Cookie_Parm('FGName')
%Prefix = $Web_Cookie_Parm('PREFIX')
%Source = $Web_Cookie_Parm('SOURCE')
%fBin = $Web_Cookie_Parm('FBIN')
End If
* Create a procedure name.
%Proc = $Reverse($Parse($Reverse(%Source),'/\'))
%Proc = %Prefix with %Proc
* Store the procedure in BASE64 format unless it's text, html or java.
%Suffix = $ParseX(%Proc,'.')
%Format = 'BASE64'
If %fBin eq 'ON' Then
%fBinChecked = 'checked'
Else
%fBinChecked = ''
If $OneOf(%Suffix, -
'TXT/HTML/HTM/JAVA/JAV/RTF/CSV/DIF/EPS/INC/PL/DB/CGI/CSS/XML/DTD/UL/XSL','/') Then
%Format = 'TEXT'
End If
End If
* Start the page.
%rc = $SetG('TITLE','Upload a Procedure to Model 204')
%rc = $SetG('SUBHEAD','Upload Procedure to ' with -
$View('JOBNM') with '
')
In JANWEB Include WEB/TEMPLATE_TOP
Html
See the code for this demo.
End Html If $Web_Hdr_Parm('METHOD') eq 'POST' Then Call OpenFile(%rc, %Type, %FGName, 0210) %FGName = %Type with ' ' with %FGName * %rc = $Web_Proc_Recv(%FGName, %Proc, 'source',, %Format) If %rc Then Print 'SUCCESS! The procedure ' with %Proc with - ' was saved in ' with %FGName Else Print 'No go. The procedure ' with %Proc with - ' was not saved in ' with %FGName with '. That''s because we intentionallly' with - ' disabled the $Web_Proc_Recv function in the demo. You can make it work' with - ' at your own site by un-commenting this function call.' End If End If HtmlUse your browser's "back" button to return to the form and try again.
End Html %rc = $Web_Done Stop End Subroutine OpenFile END