These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

File Upload - Browse functionality in ADOBE

Pallavi_Gondkar
Registered: Oct 2 2008
Posts: 22
Answered

Hi All,I am developing an AIF (Adobe Interactive Form) where I have to attach two files on an Interactive Adobe Form.

I am putting two fields and their respective individual BROWSE buttons on the form. I am writing JavaScript on the click even of BROWSE buttons.The issue is when the second file is selected it is overwriting the previously attached file. In other words in the Attachment tab on the Adobe Page, the first file is getting replaced by second one as soon as the second file is selected.
As per the requirement Below is the code that I am writing on CLICK event of BROWSE button.

var sFile;
event.target.importDataObject(sFile);var oFile;
oFile = event.target.getDataObject(sFile);
this.parent.parent.Sub_Form_Fields_Mass.ZPATH1.rawValue = oFile.path;

Every helpful reply would be appriciated!!!

Thanks,
Pallavi

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It would be helpful if we knew specifically what forms technology you were using and the version/type of Acrobat. And since the code is doing a restricted operation, is this only done in Acrobat Pro? or have Reader "Embedding Rights" been added to the form so it will work in Reader?

The first argument to the "importDataObject()" function is the name of the attachement, i.e., it's unique identifier in Acrobat. If you use the same name for two files then the second one will overwrite the first. Is "sFile" a different value for both? I see where "sFile" is defined, but where is it's value set?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Pallavi_Gondkar
Registered: Oct 2 2008
Posts: 22
Hi Thom,

Thanks for prompt response!!!
I am using Interactive Adobe Form in SAP ABAP.
Version is Acrobat Reader 7.0, I am not sure if I have been able to answer this properly or not.

For the argument, I am using same function name for both the BROWSE buttons but using different variables. below is the code that i have written for respective BROWSE buttons:

BROWSE1:

var sFile;
event.target.importDataObject(sFile);
var oFile;
oFile = event.target.getDataObject(sFile);
this.parent.parent.Sub_Form_Fields_Mass.ZPATH1.rawValue = oFile.path;

BROWSE2:

var aFile;
event.target.importDataObject(aFile);
var bFile;
bFile = event.target.getDataObject(aFile);
this.parent.parent.Sub_Form_Fields_Mass.ZPATH2.rawValue = bFile.path;

PATH1 and PATH2 are two fields to which these BROWSE buttons have been associated with. I get the file name as return value to these fields ocne I select a file using Browse Button.

Since, I am using different variables for both the buttons it should not be over writing the previous attachment. By the way I am SAP ABAP resource and dont have much knowledge about Adobe and Acro JS, please help me out to overcome this problem.

Thanks,
Pallavi.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It matters not what variables are used, it's the value of the variable that counts.

Since neither variable is set, they both will translate to a string value of "undefined". So it's expected that one import would overwrite the other. You can check on this by getting the name of the of the embedded file. Run this code in the console window.

this.dataObjects[0].name;

Try changing the variable declaration to this

var sFile = "File1";

and

var aFile = "File2";

I think you'll see a difference.

On another note. This function will not operate in Acrobat Reader without Reader "Embedded" Rights enabling.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Pallavi_Gondkar
Registered: Oct 2 2008
Posts: 22
Hi Thom,

"Variable was not set"...It was a great caught!!!
Its working now...Thanks for your valuable inputs. I highly appreciate your efforts and help.

Thanks,
Pallavi.