Image Path

Image Path

Postby Silvio.Falconi » Wed Sep 05, 2018 11:00 pm

On a procedure I must save the Path of Image

the user can select an image from computer and insert on the record

When the procedure save the record , save also the path of the image

I wish have a path like ".\images\fineimage.png"

Where the ".\images\" is the default path sample cPathImage:= ".\images\"

1. How I can have the name of the Image and the extension to save as ".\images\fineimage.png" ?
2. When I save the image the procedure must copy the file image from the folder of Computer where the final user selected the image into cPathImage

Do you have a small test trying to make it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm

Re: Image Path

Postby Antonio Linares » Fri Sep 07, 2018 8:31 am

Silvio,

1. The returned value of cGetFile() contains the path and filename
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Image Path

Postby Silvio.Falconi » Fri Sep 07, 2018 8:42 am

yes antonio

but I have for a sample C:\Program Files (x86)\EasyBeach\images\image.png

I wish only .\images\image.png

I remember there are some function but I not found it

Now I found on Harbour

hb_PathJoin( "C:\Temp", ".." ) ==> C:\..
hb_PathNormalize( hb_PathJoin( "C:\Temp", ".." ) ) ==> C:\..
hb_PathJoin( "C:\Temp\xxxx", ".." ) ==> C:\Temp\..
hb_PathNormalize( hb_PathJoin( "C:\Temp\xxxx", ".." ) ) ==> C:

but not run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm

Re: Image Path

Postby James Bott » Mon Sep 10, 2018 2:53 pm

Silvio,

If you already know the full path including the filename, then you can get just the path like this:

cFilePath( "C:\Program Files (x86)\EasyBeach\images\image.png" )

cFilePath() is a built-in function.

I will return: "C:\Program Files (x86)\EasyBeach\images\" (without the quotes).

Is that what you need?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Image Path

Postby James Bott » Mon Sep 10, 2018 4:33 pm

Silvio,

Or, maybe this is what you want?

Code: Select all  Expand view
#include "fivewin.ch"

Function Main()
   Local cImageLocation

   cImageLocation :="C:\Program Files (x86)\EasyBeach\images\image.png"

   msgInfo( myPath(cImageLocation),"myPath(cImageLocation)" )  // returns ".\images\image.png"

Return nil


Function MyPath(cPath)
   Local nNewPath,nPos,nNewPos
   cNewPath:= cFilePath(cPath)
   cNewPath:= left(cNewPath,len(cNewPath)-1) // strip off last \
   nPos:= RAT("\", cNewPath)                 // find pos of 2nd to last \
   nNewPos:= len(cPath) - nPos              
   cNewPath:= "
.\" + right(cPath,nNewPos)
Return cNewPath


FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: wilsongamboa and 114 guests