Extracting the filename from an attachment

M

mfleet1973

Hi gang,

Is it possible to extract the filename from an attachment object? If
so how?

Also, if it is possible, can I set the value of another field with the
result of the extraction? I would like to do this as soon as the user
selects a file to attach.

Thanks a lot!

Mike.
 
S

S.Y.M. Wong-A-Ton

Perhaps this article might help:
http://blogs.msdn.com/infopath/archive/2004/03/18/92221.aspx

The information you require is in the header of the base64 encoded value of
the attachment control. Since I do not know of any way to convert a base64
encoded string in script, your best bet is to use managed code do this and
extract the information you require. Once extracted, you can use it in
another field on the form.
 
M

mfleet1973

Thanks for responding.

Is it possible to extract the information as soon as the user selects a
file to attach to the form?

Thanks for replying.

Mike.
 
S

S.Y.M. Wong-A-Ton

The file attachment control does not appear to support events. What you can
do is add a helper field to your form and set a rule on the file attachment
control to set the value of this helper field to whatever. This will trigger
the OnAfterChange event of the helper field, and you can then use this event
to write your code in to extract the information from the file attachment
control. So the information will be extracted immediately AFTER the user has
selected a file.
 
M

mfleet1973

It works! Thanks!
S.Y.M. Wong-A-Ton said:
The file attachment control does not appear to support events. What you can
do is add a helper field to your form and set a rule on the file attachment
control to set the value of this helper field to whatever. This will trigger
the OnAfterChange event of the helper field, and you can then use this event
to write your code in to extract the information from the file attachment
control. So the information will be extracted immediately AFTER the user has
selected a file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top