Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Uploading files via FTP
Uploading files via FTP [message #6421] |
Sat, 11 November 2006 17:58  |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
This nice little piece of U++ code is responsible for "syncing" www.ultimatepp.org content:
Vector<String> upload;
{
FindFile ff(AppendFileName(targetdir, "*.*"));
while(ff) {
if(ff.IsFile()) {
String s = LoadFile(AppendFileName(targetdir, ff.GetName()));
String f = AppendFileName(diffdir, ff.GetName());
if(LoadFile(f) != s) {
upload.Add(ff.GetName());
}
}
ff.Next();
}
}
if(upload.GetCount()) {
Progress pi;
pi.SetTotal(upload.GetCount());
FtpClient ftp;
pi.Create();
pi.SetText("connecting...");
if(!ftp.Connect(GetIniKey("UppFtp"), GetIniKey("UppFtpUsr"), GetIniKey("UppFtpPwd"), true)) {
Exclamation("Unable to connect!" + ftp.GetError());
return;
}
if(!ftp.Cd("www")) {
Exclamation("Unable to 'cd www'");
return;
}
for(int i = 0; i < upload.GetCount(); i++) {
pi.SetText(upload[i]);
if(pi.StepCanceled())
break;
String s = LoadFile(AppendFileName(targetdir, upload[i]));
if(!ftp.Save(GetFileName(upload[i]), s)) {
Exclamation("FTP error (file upload): " + ftp.GetError());
return;
}
SaveFile(AppendFileName(diffdir, ff.GetName()), s);
}
}
Mirek
|
|
|
|
|
Re: Uploading files via FTP [message #20015 is a reply to message #20014] |
Tue, 10 February 2009 00:55   |
andrei_natanael
Messages: 262 Registered: January 2009
|
Experienced Member |
|
|
The problem is here:
you're using it incorrect, you shouldn't use "ftp://" URI scheme name because ftp client doesn't understand it. A ftp URI is just an uri like "ftp.someftp.com" or "someftp.com"(without ftp:// scheme), in essence matter just the connection port(a ftp server should listen on it) and protocol(FTP).
[Updated on: Tue, 10 February 2009 00:55] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 13:19:29 CEST 2025
Total time taken to generate the page: 0.02986 seconds
|