Gday all (interesting day in Sydney today ???)
I viewed Selwyn's video on transforming an image filename that has been uploaded to a specific name (rather than using the GUID allocated filename). All is working well on the upload although if I delete the image, then upload a new image, then the GUID filename is again allocated and the only way I can have the specific filename allocated is through deleting the data directly in MYSQL.
Can anyone shed any light on how I can do this through Xbasic or similar.
On another matter, I also found that if I capture the image through a camera and then upload it, it is not allocated the directory filename I setup in the Upload Image.No image or camera upload image MYSQL data.jpgImage deleted and new image uplaoded MYSQL data.jpgImage Upload Screen.jpg
The code I used to rename the files is below.
Thanks
Paul
if rtc.flagRecordWasSaved
dim sql as c
sql = "select a1idconsta, a1contname, a1firstnam, a1lastname, a1imagefilename from a1contstaf where a1idconsta = :pk"
dim args as sql::Arguments
dim cn as sql::Connection
flag = cn.open("::Name::CCS")
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.CallResult.text) + "');"
end
end if
args.add("pk", convert_type(rtc.primaryTablePrimaryKey,"N"))
dim flag as l
flag = cn.Execute(sql,args)
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.CallResult.text) + "');"
cn.Close()
end
end if
dim rs as sql::ResultSet
rs = cn.ResultSet
dim imageName as c
dim filename as c
imageName = rs.Data("a1contname")+"_"+rs.Data("a1firstnam")+"_"+rs.Data("a1lastname")
filename = rs.Data("a1imagefilename")
cn.FreeResult()
dim filename2 as c
filename2 = file.filename_parse(filename,"dp") +imageName+file.filename_parse(filename,"e")
if file.exists(filename) then
file.rename(filename,filename2)
end if
dim sql2 as c
sql2="update a1contstaf set a1imagefilename = :fn1 where a1idconsta = :pk"
args.Add("fn1",filename2)
flag = cn.Execute(sql2,args)
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.ResultSet.text) + "');"
cn.Close()
end
end if
cn.Close()
end if
I viewed Selwyn's video on transforming an image filename that has been uploaded to a specific name (rather than using the GUID allocated filename). All is working well on the upload although if I delete the image, then upload a new image, then the GUID filename is again allocated and the only way I can have the specific filename allocated is through deleting the data directly in MYSQL.
Can anyone shed any light on how I can do this through Xbasic or similar.
On another matter, I also found that if I capture the image through a camera and then upload it, it is not allocated the directory filename I setup in the Upload Image.No image or camera upload image MYSQL data.jpgImage deleted and new image uplaoded MYSQL data.jpgImage Upload Screen.jpg
The code I used to rename the files is below.
Thanks
Paul
if rtc.flagRecordWasSaved
dim sql as c
sql = "select a1idconsta, a1contname, a1firstnam, a1lastname, a1imagefilename from a1contstaf where a1idconsta = :pk"
dim args as sql::Arguments
dim cn as sql::Connection
flag = cn.open("::Name::CCS")
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.CallResult.text) + "');"
end
end if
args.add("pk", convert_type(rtc.primaryTablePrimaryKey,"N"))
dim flag as l
flag = cn.Execute(sql,args)
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.CallResult.text) + "');"
cn.Close()
end
end if
dim rs as sql::ResultSet
rs = cn.ResultSet
dim imageName as c
dim filename as c
imageName = rs.Data("a1contname")+"_"+rs.Data("a1firstnam")+"_"+rs.Data("a1lastname")
filename = rs.Data("a1imagefilename")
cn.FreeResult()
dim filename2 as c
filename2 = file.filename_parse(filename,"dp") +imageName+file.filename_parse(filename,"e")
if file.exists(filename) then
file.rename(filename,filename2)
end if
dim sql2 as c
sql2="update a1contstaf set a1imagefilename = :fn1 where a1idconsta = :pk"
args.Add("fn1",filename2)
flag = cn.Execute(sql2,args)
if flag = .f. then
e.javascript = e.javascript + "alert('" + js_escape(cn.ResultSet.text) + "');"
cn.Close()
end
end if
cn.Close()
end if