DEFINE VAR mFile AS memptr NO-UNDO.
DEFINE VAR cfile_dest AS memptr NO-UNDO.
ASSIGN mFile = get-binary-data("fileattached")
cfile_dest = get-config("fileUploadDirectory":U) + '\' + entry(num-entries(cfile),cfile,'\')
IF mFile <> ? THEN DO transaction: /*we got a valid pointer*/
{&out} '<div align=center id="infotitle">Sending attachment to Server...</div>'.
find first uploaded_file where uploaded_file.isr_no = get-value('record_key')
and uploaded_file.file_name = cfile
exclusive-lock no-error.
/*copy file to upload directory-configured in webspeed broker*/
COPY-LOB FROM mFile TO file cfile_dest NO-CONVERT no-error.
IF not avail uploaded_file THEN do:
create uploaded_file.
assign uploaded_file.isr_no = get-value('record_key')
uploaded_file.file_name = cfile
uploaded_file.gen_file_name = docprefix + string(next-value(next_document_no),'999999') + '.' + entry(2,cfile,'.')
no-error.
END.
/*copy file from upload directory-configured to field of record*/
COPY-LOB FROM file cfile_dest TO uploaded_file.file_obj NO-CONVERT no-error.
IF avail uploaded_file THEN do:
IF uploaded_file.file_obj = ? THEN
assign lfileOk = false.
end.
else
assign lfileOk = false.
if not lfileOk then do:
{&OUT} '<div align=center class="error_message">Error: Invalid Attachment! Please check your entry.<br /><br />'.
{&OUT} '<input type="button" id="logicalbutton" name="back" value="Back" onclick="history.back();" /> <input type="submit" id="logicalbutton" value="Cancel">'.
{&OUT} '</div>'.
end.
else do:
{&OUT} '<div align="center" id="infotitle">Attachment successfully uploaded!<br /><br />'.
{&OUT} '<input type="submit" name="Send" value="View Request List" onclick="action=' + "'" + 'requestlist' + "'" + ';" />'.
{&OUT} '</div>'.
assign lfileOk = false.
end.
end.
I'm uploading both text and binary files with this code