Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Uploading files via a web browser to OpenInsight using OECGI2 (Web) ====== ====== ====== ==== Created at 14 MAR 2008 11:20AM ==== You can upload files via a web browser to your OpenInsight application via OECGI2. There are two registry settings that control file uploads. **FileMode ** There are 3 possible settings: 0 = File Uploading is disabled. 1 = upload file to the directory specified in FilePath 2 = upload file to the directory specified in FilePath, and delete it when the OECGI2 request is completed. 3 = upload the filedirectly to OpenInsight. You can only upload textfiles (text,csv, xml, html etc) via this mode. It does not support binary files like images or pdf s. Use mode 1 or 2 for binary file types. // Note: For modes 1 & 2, OECGI2 will assign a temporary filename to the// // file physically located in the FilePath.The name of the temporary file will// // be passed to OpenInsight in therequest string and accessible via// // INET_QUERYPARAMS// //// // Note3: OECGI2 also adds an input tag of the form <filetag>.length(in// // this example, myfilename.length)to pass you the size of the uploaded file.// //// **FilePath ** The directory where the file will be uploaded for modes 1 & 2. This path is relative to the directory where OECGI2.EXE is located. Example 1: OECGI2.EXE is located inc:\inetpub\scripts FilePath is set to upload\ In this scenario OECGI2will upload the file to c:\inetpub\scripts\upload Example 2: OECGI2.EXE is located inc:\inetpub\scripts FilePath is set to \upload\ In this scenario OECGI2will upload the file to c:\inetpub\upload // Note1: You must add a backslash \ to the end of the FilePath setting.// // Note2: You must enable write permissions to the upload directory// // specified in FilePath// // Note3: FilePath is ignored when FileMode is set to 3// //// Here is an example of the registry settings for: FileMode = 2 FilePath =\upload\ These settings will upload a file to the c:\inetpub\upload directory on the webserver and will delete the file once your inet procedure has completed. Below is an example HTML page which will upload a file to OpenInsightvia OECGI2. File uploads in HTML are handled by a //form// tag and the //input// tagwith the type set to //file//. Please note the //enctype// //// attribute in the form element. You need to set this element as per the example so that your webserver will upload the file. <html> <body> <formname="myform" action="\cgibin\ oecgi2.exe\inet_myloadproc" method="POST" enctype="multipart/formdata"> <inputname="myfilename" type="file"size="50"> </form> </body> </html> The BASIC+ code for the inet_myloadproc Stored Procedure is below. Function inet_myuploadproc(request) %%//%%Sample code to demonstrate how to upload a file to OpenInsight via OECGI2 declare function inet_query Param %%//%%set the upload directory uploadDir = c:\inetpub\upload\ %%//%%For FileMode = 1 & 2 %%//%%Get the name of the file the user uploaded to us filename = inet_queryparam(request, myfilename ) %%//%%Get the name of the file stored in the directory specified in FilePath uploaded FileName = inet_query param(request, myfilename.filename ) %%//%%Now copy the uploaded file to somewhere on our server so that we can process it osread data from uploadDir:uploadFileNamethen oswrite data ondrive(): \ :filename end %%//%%For FileMode = 3 %%//%%The actual data file is passed to us via the request string data = inet_query param(request, myfilename ) return thanks for uploading you file to us // Note1: FileMode = 2 will delete the temporary file from the upload directory after// // your BASIC+ procedure completes.// // Note2: We did not create an input tag in our html page with the name of// // myfilename.filename. This is added to the request string by OECGI2 to pass you the// // temporary filename it created in the upload FilePath directory.// kb/kb_articles/kb0251.txt Last modified: 2024/01/30 13:36by 127.0.0.1