Question
· Aug 26

ZEN Webpage for uploading and downloading a file without unix access

Hi, 

I'm new to ZEN . I want to create a Zen web page to upload a local file & save it to server and download the same file to other sever.

This needs to be implemented without unix access (using only IRIS code only).

I gave it a try with below basic code (just to upload file) , the page is loading with file uploader but after uploading a local txt file, the pFile object is not getting created.

$IsObject (pFile) is returning 0.

Please assist!

Thanks in advance!

 

Class MyApp.BasicFileMgr Extends %ZEN.Component.page {

Parameter PAGETITLE= "File Upload & Download";

XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] {
‹page xmIns= "http://www.intersystems.com/zen" title="">
                 

                  <html id="title">Upload and Download Files/html>

                   <fileUpload name="uploadedFile" /›
                 ‹button id="myButton" caption="Upload" onclick="zenPage.uploadFile(zenPage-getComponentById ('uploadedFile'))" /›
</page>
}

Method uploadFile(pFile As %ZEN.Component.fileUpload) As %Status [ ZenMethod ] {
    try {
         Set ^TEST($I(row))=$isobject(pFile)
         set fileStream = pFile.GetUploadedFile()
         if fileStream '= "" {
        set filename = fileStream.GetFilename()
        set saveDir = ##class%File) NormalizeDirectory ("c: \intersystems liris \ngr \user \uploads|")
        d ##class(%File).CreateDirectory(saveDir)
        set savePath=savedir_fileName
        d fileStream.SaveToFile(savePath)
        }
    }
        
    catch ex {
        write "Upload Error: "_ex.DisplayString()
    }
    quit $$$0K
}
}

Discussion (1)2
Log in or sign up to continue