JavaScript Code for Attachment, Text Field & Clear files Button

Copy link to clipboard
Copied
Good day, Is it possible to get the Java script code to add attachment(file), Text field to show the file name that was attached and the Clear files button to clear the text field and remove attachment. This is what i am looking for on the form i am trying to create. Any help would be greatly appreciated. Thanks
Copy link to clipboard
Copied
Yes and no. The code for adding an attachment is this:
this.importDataObject("TheObject");
This prompts the user with a file open dialog. The name "TheObject" is the name of this attachment.
use this code to remove
this.removeDataObject("TheObject);
I've already answered a question about showing the attachment name here:
Be aware that importing a data object can be a privileged operation, and that this code will only work in Reader if the PDF has special privileges.
Use the Acrobat JavaScript Reference early and often

