Helma logo
helma.org » Home > docs > examples > FTP an uploaded file

FTP an uploaded file

This script retrieves the data of a file sent to Hop via an html upload form and saves it on the server machine using FTP.

var upload = req.data.myUpload;
if (upload) {
  res.write("Error: " + req.data.uploadError + "<br>");
  res.write("Content-type: " + upload.contentType);
  var ftp = new FtpClient("remotehost");
  ftp.login("user", "pass");
  ftp.binary();
  ftp.putString(upload.getContent(), "file.gif");
  ftp.logout();
}
A corresponding html form might look like this:
<form name="uploadForm" enctype=multipart/form-data method="post">
File to upload:
<input type="file" name="myUpload">
<input type="submit" value="1">
</form>


Up: Code Snippets
Previous: Managing Subscriptions Next: Using JavaMail directly

... comment


Page last modified on 2002-06-27 16:24 by hns