48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
// ******************************************
|
|
// * $Id$
|
|
// *
|
|
// * sendFTP()
|
|
// *
|
|
// * Verstuur gegevens via FTP
|
|
// *
|
|
// ******************************************
|
|
function sendFTP(p_connect, p_file, p_data, p_path)
|
|
{
|
|
var objFso = new ActiveXObject("Scripting.FileSystemObject");
|
|
|
|
Log2File(2, "*> sendFTP");
|
|
var FTPsend = false;
|
|
if (p_connect.Connected)
|
|
{
|
|
try
|
|
{
|
|
if (p_path)
|
|
{
|
|
objFile = objFso.GetFile(p_path);
|
|
Log2File(1, "Transfer file: " + p_file + " (size: " + objFile.Size + ")");
|
|
p_connect.ftpconnection.PutFile(p_file, p_path); // Hiermee kunnen ook binary bestanden gekopieerd worden.
|
|
}
|
|
else
|
|
{ // Forceer p_data altijd naar utf-8
|
|
var tempfile = "../../../temp/puo_" + objFso.GetTempName();
|
|
p_data.SaveToFile(tempfile);
|
|
Log2File(1, "Transfer data as file: " + p_file + " (size: " + p_data.Size + ")");
|
|
p_connect.ftpconnection.PutFile(p_file, tempfile); // Hiermee kunnen ook binary bestanden gekopieerd worden.
|
|
if (S("puo_loglevel") < 4)
|
|
objFso.DeleteFile(tempfile);
|
|
// schrijft geen utf-8
|
|
// p_connect.ftpconnection.PutFileFromTextData(p_file, p_data.ReadText()); // Alleen een tekst-string schrijven.
|
|
}
|
|
FTPsend = true;
|
|
}
|
|
catch(e)
|
|
{
|
|
Log2File(0, "Error sending " + p_file + ": " + e.description);
|
|
FTPsend = false;
|
|
}
|
|
}
|
|
Log2File(2, "*< sendFTP");
|
|
|
|
return FTPsend;
|
|
}
|