FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Image link option
Posts: 1402
Joined: Mon May 14, 2007 09:49 AM

Image link option

Posted: Wed Apr 08, 2026 08:46 PM

Hi,

There is a link to the picture on someone else's website.

<img loading="lazy" decoding="async" style="width: 100%; height: 100%; background: center center / cover; object-fit: cover;"
class="img image svelte-1aizpza" src="https://i.oneme.ru/i?r=BTE2sh_eZW7g8kugOdIm2Notn5Uj_vutw0JZOuoJpRlHQwUfwMhzHGGtcQEW7VWfF3I" alt="">

Is it possible to pull out an image and save it as a file?

Posts: 0
Joined: Wed Aug 26, 2026 09:41 AM

Re: Image link option

Posted: Fri Aug 28, 2026 03:50 PM
Hello,

Yes, it is possible to download an image from a URL and save it as a file using Harbour or xHarbour. You can use network functions to fetch the image data and then write it to a local file.

For example, in Harbour, you might use the `hDownload()` function from the HbNet library:

Local cUrl := "https://example.com/path/to/image.jpg"
Local cLocalFile := "downloaded_image.jpg"

IF hDownload( cUrl, cLocalFile )
   ? "Image saved successfully to", cLocalFile
ELSE
   ? "Error downloading image"
ENDIF


Make sure that your project includes the necessary network libraries (like `hbnet`) and that you handle any exceptions or errors appropriately. If you're working in a specific framework like FiveWin, check the documentation for built-in functions or classes that might simplify this process.

If you need more details or have further questions, feel free to ask!

---
Respuesta generada por Inteligencia Artificial usando el modelo mimo-v2.5-free via OpenCode Zen. Puede contener errores; por favor verifiquela antes de aplicar.
AI-generated reply using the mimo-v2.5-free model via OpenCode Zen. May contain mistakes; please verify before applying.
Posts: 8716
Joined: Tue Dec 20, 2005 07:36 PM

Re: Image link option

Posted: Sat Aug 29, 2026 02:33 PM
// C:\FWH2603\SAMPLES\IMGDOWN2.PRG

#include "Fivewin.ch"

REQUEST HB_GT_GUI_DEFAULT

FUNCTION Main()

   IF FILE( "c:\TEMP\Imagem2.jpg" )

  DELETEFILE( "c:\TEMP\Imagem2.jpg" )

   ENDIF

   MsgRun( "Aguarde o Download...", "Espere", { || DownloadFile() } )

RETURN NIL

FUNCTION DownloadFile()

   LOCAL oServerWS, oADODBStream

   #ifdef __XHARBOUR__  // PERFEITO COM XHARBOUR( I Like )

  Try

     Try
        oServerWS := CreateObject( 'MSXML2.XMLHTTP' )
     Catch
        oServerWS := CreateObject( 'Microsoft.XMLHTTP' )
     End

  Catch

     MsgInfo( 'Erro na Criação do Serviço' )

     RETURN NIL

  End

   #else

  Try

     Try
        oServerWS := win_OleCreateObject( 'MSXML2.XMLHTTP' )
     Catch
        oServerWS := win_OleCreateObject( 'Microsoft.XMLHTTP' )
     End

  Catch

     MsgInfo( 'Erro na Criação do Serviço! Com Harbour', 'Atenção!' )

     RETURN NIL

  End

   #endif

   oADODBStream := CREATEOBJECT( "Adodb.Stream" )

   oServerWS:Open( "GET", "https://i.oneme.ru/i?r=BTE2sh_eZW7g8kugOdIm2Notn5Uj_vutw0JZOuoJpRlHQwUfwMhzHGGtcQEW7VWfF3I", .F. )
   oServerWS:Send()

   oADODBStream:Type := 1
   oADODBStream:Open()
   oADODBStream:Write( oServerWS:ResponseBody )
   oADODBStream:SaveToFile( "c:\TEMP\Imagem2.jpg", 2 )

   IF FILE( "c:\TEMP\Imagem2.jpg" )

  MsgInfo( "Imagem baixada com sucesso!", "Sucesso" )

   ELSE

  MsgStop( "Erro ao baixar a imagem.", "Erro" )

   ENDIF

RETURN NIL

// FIN / END

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8716
Joined: Tue Dec 20, 2005 07:36 PM

Re: Image link option

Posted: Sat Aug 29, 2026 02:35 PM
// C:\FWH2603\SAMPLES\IMGDOWN.PRG

#include "fivewin.ch"

REQUEST HB_GT_GUI_DEFAULT

FUNCTION Main()

   LOCAL cUrl := "https://i.oneme.ru/i?r=BTE2sh_eZW7g8kugOdIm2Notn5Uj_vutw0JZOuoJpRlHQwUfwMhzHGGtcQEW7VWfF3I"
   LOCAL cLocal := "c:\TEMP\imagem.jpg"
   LOCAL nRet

   nRet := URLDownloadToFile( 0, cUrl, cLocal, 0, 0 )

   IF nRet == 0

  MsgInfo( "Imagem baixada com sucesso!", "Sucesso" )

   ELSE

  MsgStop( "Erro ao baixar a imagem.", "Erro" )

   ENDIF

RETURN NIL

DLL32 FUNCTION URLDownloadToFile( pUnk AS LONG, cURL AS LPSTR, cFileName AS LPSTR, nReserved AS LONG, nFnCB AS LONG ) AS LONG ;
   PASCAL FROM "URLDownloadToFileA" ;
   LIB "urlmon.dll"

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion