Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP connection and copying file using Javascript

Tags:

javascript

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.

like image 559
zingy Avatar asked Jan 10 '16 08:01

zingy


People also ask

How could I connect to an FTP server using a Javascript?

To make JS FTP-friendly, one would need to request FTP standard to allow CORS "headers" or so. The mozilla docs have changed to specifically remove the part about "other protocols". Now just says Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML.

How do I upload files to an FTP automatically?

Setting up automatic FTP scheduling is as easy as right-clicking on the folder or directory you want to schedule, and clicking Schedule. In the Task Scheduler section you'll be able to name the task, and set a date and time for the transfer to occur.


1 Answers

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.

like image 50
Alfabravo Avatar answered Sep 19 '22 18:09

Alfabravo