{"id":30571,"date":"2023-05-04T10:07:12","date_gmt":"2023-05-04T08:07:12","guid":{"rendered":"https:\/\/help.qualiware.it\/qw-help\/?p=30571"},"modified":"2023-05-04T10:49:26","modified_gmt":"2023-05-04T08:49:26","slug":"caricare-files-in-uno-zip-allinterno-dei-documenti-collegati","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/caricare-files-in-uno-zip-allinterno-dei-documenti-collegati\/","title":{"rendered":"Caricare files in uno zip all&#8217;interno dei documenti collegati"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">' questo script \u00e8 da inserire all'interno della procedura postback di UploadFile\r\n' si occupa di raccogliere i files caricati all'interno di uno zip, e di inserirli nei documenti collegati\r\n\r\nIf ParameterAll.Size &gt; 0 Then\r\n\r\n    Dim CODDOC As String = String2Array(form.GetCodDoc(), \"|\")(1) &amp; \"|\" &amp; String2Array(form.GetCodDoc(), \"|\")(2) &amp; \"|\" &amp; String2Array(form.GetCodDoc(), \"|\")(3) &amp; \"|\"\r\n\r\n\r\n    Dim i As Integer\r\n    Dim files As New DBArray\r\n    Dim filenames As New DBArray\r\n\r\n\r\n\r\n    ' parameterAll \u00e8 la lista di parametri\r\n    ' ogni elemento dispari \u00e8 un file, mentre ogni elemento pari \u00e8 il nome del file all'indice precedente\r\n    For i = 1 To ParameterAll.size Step 2\r\n        files.Add(ParameterAll(i))\r\n        filenames.Add(ParameterAll(i + 1))\r\n    Next\r\n\r\n\r\n\r\n    Dim zip As New qwlib.Zipper\r\n    Dim path As String ' percorso del file da caricare in QualiWare\r\n    Dim nomefile As String ' nome definitivo che il file avr\u00e0 in QualiWare\r\n\r\n    Dim errmsg As String = \"\"\r\n    Dim errore As Boolean = False\r\n\r\n\r\n\r\n\r\n    If ParameterAll.size = 2 Then\r\n        ' il file caricato \u00e8 uno solo, quindi volendo si pu\u00f2 evitare di creare uno zip\r\n        path = files(1)\r\n        nomefile = filenames(1)\r\n    Else\r\n        path = funique(Q95_PATH_TEMP &amp; \"\\\" &amp; \"????????.ZIP\") ' genera un nome unico di 8 caratteri per lo zip\r\n        nomefile = Today().ToString(\"dd-MM-yyyy\") &amp; \".zip\" ' crea il nome dello zip. in questo esempio viene utilizzata la data odierna\r\n\r\n        Try\r\n            zip.GenerateZipFile(path, files, filenames)\r\n        Catch ex As System.Exception\r\n            errore = True\r\n            Form.Alert(ex.Message &amp; vbCrLf &amp; vbCrLf &amp; ex.StackTrace, \"ERROR\")\r\n        End Try\r\n\r\n    End If\r\n\r\n\r\n\r\n    If Not errore Then\r\n        Link_Doc(Form.GetDataBase(), \"DW\", CODDOC, \"**\", path, 5, Nothing, errmsg, nomefile)\r\n\r\n        If Not String.IsNullOrEmpty(errmsg) Then\r\n            Form.Alert(\"It was not possible to insert the File in the Linked Documents : \" &amp; nomefile &amp; vbCrLf &amp; \"Errore: \" &amp; vbCrLf &amp; errmsg)\r\n        End If\r\n\r\n    End If\r\n\r\n    Form.RefreshLinkDoc()\r\nEnd If<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; questo script \u00e8 da inserire all&#8217;interno della procedura postback di UploadFile &#8216; si occupa di raccogliere i files caricati all&#8217;interno di uno zip, e di inserirli nei documenti collegati If ParameterAll.Size &gt; 0 Then Dim CODDOC As String = String2Array(form.GetCodDoc(), &#8220;|&#8221;)(1) &amp; &#8220;|&#8221; &amp; String2Array(form.GetCodDoc(), &#8220;|&#8221;)(2) &amp; &#8220;|&#8221; &amp; String2Array(form.GetCodDoc(), &#8220;|&#8221;)(3) &amp; &#8220;|&#8221; Dim&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/30571"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=30571"}],"version-history":[{"count":4,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/30571\/revisions"}],"predecessor-version":[{"id":30575,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/30571\/revisions\/30575"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=30571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=30571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=30571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}