Saving a photo with extension
Posted: Wed Sep 18, 2024 4:02 pm
I need to save a file in the archive with the extension ( I not Know wich is the extension of the file) ,
the user selects the file i.e. a photo,
the procedure must rename the photo with the student's matriculation number (nMatricola)
I made :
to rename the file cfotografia into new file cFileNew I made
to save I use the copyfile function (found in fwh sample)
it happens that sometimes it works and sometimes it saves the file in the cImgPath folder without extension but only with the file name i.e. with the student's matriculation number (nmatricola) and then saves it in the oAlunno:foto field
the function RelativePath() - it gives me the name of the folder without the file
the function UrlImage() - it gives me the file name without the folder name
How I can resolve it ?
the user selects the file i.e. a photo,
the procedure must rename the photo with the student's matriculation number (nMatricola)
I made :
Code: Select all | Expand
nMatricola:= oAlunno:matricola // student's matriculation number
cExt := ltrim(Right(cfotografia,4)) // the extension of file
cRelativePath:= RelativePath(cfotografia) // give the folder of file loaded
cFileNew:=cRelativePath+alltrim(nMatricola)+cExt //save the new name file with extension
Code: Select all | Expand
while FRename( cfotografia, cFileNew ) != 0
SysWait()
end
Code: Select all | Expand
AaDd(aSource,(cFileNew) )
AaDD(aTarget,cImgPath+UrlImage(cFileNew))
CopyFiles(aSource,aTarget,)
Code: Select all | Expand
oAlunno:foto:= UrlImage(cFileNew)
oAlunno:Save()
the function RelativePath() - it gives me the name of the folder without the file
the function UrlImage() - it gives me the file name without the folder name
How I can resolve it ?