How to upload a file from the client?

1 minute read time.

You may have a need to upload a file to the server, and in the past you may have used COPSRV routine from ORDSYS.

On V6 the limit that this routine had was that, you did not know the file name of the file that is getting transferred to the server, and you had to define the file name for the destination.
But things have changed on newer version.

Before we get to the example review online help title "How to manage files in the storage area"

As you noted in the online help, in the new version COPSRV will copy the file to server TMP directory. So in below example I am going to use another routine MOVE from ORDSYS to move the file to my desired location.

In this example, I am adding a button to Sales order, for transferring the file.

  1. Open Development, Script dictionary, Windows.
  2. Select OSOH window.
  3. Add a new button.

  4. Save and Validate.
  5. Open Setup, Sales, Entry transactions, Orders.
  6. Validate the entry transaction.
  7. Now open Development, Script dictionary, Script Editor.
  8. Select SPESOH and add below code.



    $ACTION

    Case ACTION

    When "EXEBOUT" : Gosub BOUTON

    Endcase

    Return

     

    ##############

     

    $BOUTON

    If BOUT="8" ###### this is the code of our button in Window dictionary


    Local Char FICSRV(250),FICCLI(250),MYPATH(250)

    Local Integer ASTATUS

    Local Integer stat

     

    FICCLI = ""

    FICSRV = filpath("tmp","","")  ######## here I am building path to tmp folder

    MYPATH= filpath("ATT\SALES","","") ########## here I am building the path to my destination folder

     

    Call COPSRV(FICCLI,FICSRV,ASTATUS) From ORDSYS

    FICSRV=FICSRV+"\"+FICCLI

    If ASTATUS = 0

        Call MOVE(FICSRV,MYPATH,stat) from ORDSYS  ### this will move the file for me

     

    Endif

    If stat =0

    Infbox("UPLOAD WAS GOOD THANKS")

    Else

    Infbox("Somethign went wrong")

    Endif

     

    Endif

    Return



  9. Save and Compile.
  10. Now when open Sales , Orders, Orders.
  11. Click on the button on right.



  12. After click on the button, you will get the following.

  13. Use the button to select the file or drag the file here, then click Ok.
  14. Now you will get the information box that it was ok.

Conclusion: You can use COPSRV to copy files to the server.