It should work (works for me at least ;)), what mozilla build are you
using? Necko folks are still changing apis might be broken in the 1.2+.
Since I'm using 1.1 I'm waiting for 1.2b before I update it.
Regards
Gilles Durys wrote:
> I'm trying to upload a file to a ftp server with the following code
> (modified from mozblog).
>
> function uploadFile() { var ioService =
> Components.classes["@mozilla.org/network/io-service;1"]
> .getService(Components.interfaces.nsIIOService); var url =
> Components.classes["@mozilla.org/network/standard-url;1"]; fileurl =
> url.createInstance(Components.interfaces.nsIURL); fileurl.spec =
> "file:///home/sco/polom.html";
>
> var srcChannel = ioService.newChannelFromURI(fileurl); var remoteUrl
> = url.createInstance(Components.interfaces.nsIURL); remoteUrl.spec =
> "ftp://sco:[EMAIL PROTECTED]/downloads/polom.txt"; var
> ftpChannel = ioService.newChannelFromURI(remoteUrl)
> .QueryInterface(Components.interfaces.nsIUploadChannel); var
> bufferedStream =
> Components.classes["@mozilla.org/network/buffered-input-stream;1"]
> .createInstance(Components.interfaces.nsIBufferedInputStream);
> bufferedStream.init(srcChannel.open(), srcChannel.contentLength);
> ftpChannel.setUploadStream(bufferedStream,null,-1);
> ftpChannel.asyncOpen(myListener(), null); }
>
> Calling that function gives me the following error:
>
> uncaught exception: [Exception... "Component returned failure code:
> 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIChannel.open]" nsresult:
> "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame ::
> uploadPic.js :: uploadFile :: line 15" data: no]
>
>
> I'm a little lost there, so any help/hint/lead is welcome.
>
--
Mike Lee
Website: http://www.exitspace.net/mike
- ftp upload Gilles Durys
- Re: ftp upload Mike Lee
- Re: ftp upload Gilles Durys
- Re: ftp upload Gilles Durys
