DataFiles in a media field.

I apologize if this has already been covered before.

It does not make sense to me that I can store a media type file in a record but not a text file. I want to belive that I am incorrect but all I can find are aftermarket plugins that allow data file import to a record.

I think I am missing something? I don’t need to view the file from the form and I don’t need to edit it either. I just need a db record to hold drawing files until I need them (preferably the same way I can load pictures).

This seems like a blindingly simple function with the image_media datatype already in place and doing what it does.

Will someone please advise me on way or the other on this issue.

thanks
-Nick-

it’s really simple, what you want:

try this:

var filenames = application.showFileOpenDialog(); 
if (filenames)//for cancel 
{ 
	controller.newRecord()
	yourcolumn = plugins.file.readFile(filenames) 
}

Hope that helps

Thanks for your help. Strangely I found that I could import a .doc to the media field and servoy would store it as “image.unknown” If I changed the extension when saving it(out of the field) then I could extract it back out as a .doc.

So the code you gave me handels the naming issue for me, Thanks.

Now I have some checking to do because after importing the file and trying to save the form change I recieve this error…

“com.servoy.j2db.ApplicationException: Cannot save form data”

Do I need to change the field type for non image data?

thanks
-Nick-

the column must be MEDIA type.

look at the file-plugin, there you can also, retrieve/store the filename, size etc… in other columns.