admin管理员组

文章数量:1290176

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.

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.

Share Improve this question edited Jan 10, 2016 at 9:37 zingy asked Jan 10, 2016 at 8:40 zingyzingy 81110 gold badges19 silver badges36 bronze badges 3
  • Good thing to see you tried that. So, what's your problem? – Alfabravo Commented Jan 10, 2016 at 9:27
  • 1 Instead of new file(...), try new File(...). Javascript is case sensitive. – Tigger Commented Jan 10, 2016 at 9:46
  • The link is broken – HoRn Commented Nov 4, 2021 at 11:59
Add a ment  | 

1 Answer 1

Reset to default 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.

本文标签: FTP connection and copying file using JavascriptStack Overflow