Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Recipe: how to upload multiple documents in Javascript using drag&drop

  • Recipe: how to upload multiple documents in Javascript using drag&drop

    Posted by Christoph Schwerdtner on November 8, 2022 at 8:24 am

    Problem: when dragging multiple documents from operating system you get a pDragValue List with one line per document. If you use $clientcommand to read every file in a loop the corresponding call to $filereadcomplete is only executed once.

    Solution:

    1. in on evDrop use instance var iDragList to save pDragValue and call $readnext

    2. new method $readnext (client executed) reads the current file in iDragList using $clientcommand(“readfile”) and increments the current line

    3. $filereadcomplete adds the file to a iFileList and calls $readnext

    dropFilesHere Button or other element with dropmode kAcceptOperatingSystem

    On evDrop

    If pDragType=kDragOperatingSystem

    Calculate iDragList as pDragValue
    Do $cinst.$readnext()
    End If

    Andreas Pfeiffer replied 1 year, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Christoph Schwerdtner

    Member
    November 8, 2022 at 8:35 am

    continued…

    $readnext (client executed)

    If iDragList.$line<iDragList.$linecount
    Calculate iDragList.$line as iDragList.$line+1
    Do $cinst.$clientcommand("readfile",row(iDragList.c4,"iFileObject",1))
    Else
    Do iDragList.$clear()
    End If

    $filereadcomplete (client executed)

    Do iFileList.$add(pIdent,iFileObject,iDragList.c1)
    Do $cinst.$readnext()

  • Andreas Pfeiffer

    Administrator
    June 9, 2023 at 12:11 pm

    Hi Christoph,

    check out the new Omnis Studio 11 JS File upload / download sample in the HUB.

    Best,

    Andreas

Log in to reply.