Jump to content
Fivewin Brasil

É possível fazer uplaod de imagem via POST usando TipLib ou outra?


Ariston Santos

Recommended Posts

Boa tarde,

Estou procurando uma solução para upload de imagens que não seja via FTP.

A ideia é seria uma solução semelhando à demonstrada abaixo, usando a TIpLib para upload de XML via POST. Queria saber se tem como enviar imagens da mesma forma.

   cDBHst := IIF("localhost" $ c_Host, "http://"+alltrim(c_Host), "http://www."+alltrim(c_Host))
   TRY
      oURL1 := TUrl():New(cDBHst+"/"+c_Php+"?uid="+GeraIdUnico())
      oHtp1 := TIpClientHttp():New(oURL1, .F.)
      oHtp1:nConnTimeout:= 3000 // 3 segundos
      if oHtp1:Open()
         If oHtp1:POST( {{"xml", c_Xml}} ) // POST acepts long queries, xml and json.
            _Json := oHtp1:ReadAll()
         Else
         	SysRefresh() ; MsgInfo('Erro no Post ' + cDBHst, 'Aviso do Sistema')
         EndIf
      Else
         SysRefresh() ; MsgInfo("Erro na conexão com "+cDBHst+"/"+c_Php, "Atenção")
      EndIf
      try ; oHtp1:Close() ; catch e ; end try
      try ; DeleteObject(oURL1) ; catch e ; end try
      try ; DeleteObject(oHtp1) ; catch e ; end try
      DeleteUrlCacheEntry(oURL1)
   CATCH oErr
      SysRefresh() ; MsgAlert("Erro: "+oErr:Description, "Ocorreu um erro")
   END
   IF ! EMPTY(_Json)
      MsgHtml(_Json, "Retorno de "+cDBHst)
   EndIf

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...