BTW this is only working in 2.0beta5
make 4 fields:
bestandspad TEXT 200
bestandsnaam TEXT 50
bestandgrootte INTEGER
media (IMAGEMEDIA)
To put files in the blob an fill the appropriate fields do this:
- Code: Select all
controller.newRecord()
filename = application.showFileOpenDialog();
if (filename)//for cancel
{
var normalizedFileName = "";
normalizedFileName = utils.stringReplace(filename,'\\','/')//make windows path like unix path
bestandspad = normalizedFileName
var idx = normalizedFileName.lastIndexOf("/");
if (idx != -1) normalizedFileName = normalizedFileName.substring(idx+1 );
bestandsnaam = normalizedFileName
media = application.readFile(filename)
bestandgrootte = plugins.file.getFileSize(filename)
}
after that, make a method that opens the files right away from out the database:
- Code: Select all
var a = bestandsnaam.lastIndexOf(".")
var b = bestandsnaam.substr(0,a)
var c = bestandsnaam.substring(a)
var filename = application.createTempFile(b,c)
application.writeFile(filename,media);
if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
application.executeProgramInBackground('rundll32', 'url.dll,FileProtocolHandler',filename)
}
Mabey someone can make the last method compatible with Macintosh or Linux/Unix.