5

I am new to javascript and am trying to write a script which can copy a photoshop file from the local drive to a FTP server. The file is opened in photoshop and the script is run inside it.

I followed documentation(pdf) on page 165.

var file_path = app.activeDocument.fullName
var file = new file ("/d/project/test_file.psd");

var ftp = new FtpConnection("ftp://192.168.1.150/DATA/") ;
ftp.login("username", "password");

ftp.cd("project")
ftp.put(file,"test_file.psd") ;

ftp.close() ;
file.close() ;

I get an error as the following:

Error 22: file does not have a constructor.
Line: 2
-> var file = new file("/d/project/test_file.psd");

I am not able to understand the issue properly.

zingy
  • 811
  • 9
  • 19
  • 35

1 Answers1

5

Assuming you are already loading the Web Access library (webaccesslib) as stated in previous pages of your documentation, please ensure you're respecting capitalization when calling class instances.

var file = new File("/d/project/test_file.psd");

Must have File with capital F. The error is saying there's no implementation of class file.

Alfabravo
  • 7,493
  • 6
  • 46
  • 82
  • Oh I get it. How silly of me to not see that. I will try and see how it works now. Thanks. – zingy Jan 10 '16 at 09:50
  • Now its pointing towards the 3rd line and displays error as "Error 22: FtpConnection does not have a constructor." – zingy Jan 10 '16 at 10:20
  • Check in the documentation, page 164, there's how to load Web Access library. `if ( !ExternalObject.webaccesslib ) { ExternalObject.webaccesslib = new ExternalObject('lib:webaccesslib'); }`. Requires you to set up some compiled library files in a given path. – Alfabravo Jan 10 '16 at 11:31
  • This seems a bit complicated than I thought. So library files need to be set up for each path which will be processed. – zingy Jan 11 '16 at 04:27
  • I am also looking into running a python script from inside photoshop. Is it possible? I found this in adobe forum "app.system( 'python '+pythonScript); " but this doesn't work. – zingy Jan 11 '16 at 10:08