Using WebUtil File Transfer
WebUtil provides a mechanism for transfering (uploading) files from client to the application Server.
The following is a working example
make sure that the webutil.cfg is configured to allow transfer operations, please note in particular the lines highlighted in bold
#NOTE: By default the file transfer is disabled as a security measure
transfer.database.enabled=TRUE
transfer.appsrv.enabled=TRUE
transfer.appsrv.workAreaRoot=
transfer.appsrv.accessControl=TRUE
#List transfer.appsrv.read.<n> directories
transfer.appsrv.read.1=c:\temp
#List transfer.appsrv.write.<n> directories
transfer.appsrv.write.1=/home/oracle
Please note that the last file indicates where you intend to write your file. This is a mandatory entry that gives the client program write access on a particular directory. In this case the client program shall write on the unix directory /home/oracle
Code
DECLARE
file_name VARCHAR2 (200);
-- RETURN IMAGE PATH WHICH TYPE JPG AND JIF
-- v_server_path VARCHAR2 (250) := get_server_path;
v_file VARCHAR2 (250);
result boolean;
BEGIN
-- invoke the file open dialog and read the complete file name with path
:firm_pic.old_file_path := client_get_file_name ('','','JPG |*.JPG|BMP |*.bpm|gif
Files |*.gif','Select a file to Upload ',open_file,TRUE);
-- get the file name and remove the path
:firm_pic.file_name := SUBSTR (:firm_pic.old_file_path,INSTR (:firm_pic.old_file_path,
file_name, -1) + 1,100);
-- Do the Transfer
result := webutil_File_transfer.Client_to_AS( v_file , '/home/oracle/'||:firm_pic.file_name);
exception
when others then
message (sqlerrm);
end;