Hi,
I am trying to create an experimental air app where I connect to the FTP server and try to upload a file to the directory. Following is the code I am using in my AIR+AJAX app:
var s = new air.Socket("www.weblancer.in", 21);
s.addEventListener(air.ProgressEvent.SOCKET_DATA, sOk);
s.addEventListener(air.Event.CONNECT, sData);
function sOk(){
var d = s.readUTFBytes(s.bytesAvailable);
window.alert(d);
}
function sData(){
s.writeUTFBytes("USER username\n");
s.writeUTFBytes("PASS password\n");
s.writeUTFBytes("CWD /public_html/dev/gaurav\n");// set the path
s.writeUTFBytes("TYPE A\n");// setting the type of the transfer
s.writeUTFBytes("PASV\n");
s.writeUTFBytes('STOR RHDSetup.txt\n');
s.writeUTFBytes("QUIT\n");
s.flush();
}
Everything happens and the file is Created in the directory of choice. But it is just creating a blank file. What I want is that I should be able to select the file from my desktop and upload that file with all its content to the server like other ftp clients do. So for this purpose I wrote the following code:
var t = air.File.desktopDirectory.resolvePath('RHDSetup.txt');
But when I try to use "t" with "STOR" it works but since "t" is an object a file with a name [object File] is created on the server.
I am stumped and Adobe has not come out with a class for ftp.
Can anybody help me?
Gaurav