I know this is a Major Noob question, but all the examples i can find are of an FTP GET not an FTP PUT. I have several of the books on QT, nothing on Opening a file and PUTing it..
All i want to do is see some examples of opening a file and using QFTP PUTing it to a remote ftp as anonymous
The transfer must be binary safe.
I have this code to update a combo box with a filename from a browse button...
void Window::browse()
{
tr
("Open File"),
QDir::currentPath());
if (!directory.isEmpty()) {
directoryComboBox->addItem(directory);
directoryComboBox->setCurrentIndex(directoryComboBox->currentIndex() + 1);
}
}
void Window::browse()
{
QString directory = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::currentPath());
if (!directory.isEmpty()) {
directoryComboBox->addItem(directory);
directoryComboBox->setCurrentIndex(directoryComboBox->currentIndex() + 1);
}
}
To copy to clipboard, switch view to plain text mode
This works fine, then when they push Send it calls "sendFile", but I cannot link the "directoryComboBox" to the QFTP PUT... and send it to the server.
Send File Code...
void Window::sendFile()
{
cancelButton->setEnabled(true);
/* This holds the remote server IP Address */
ftp->connectToHost(printerComboBox->currentText());
/* These Status labels are broken they work but show sending file allways, need to do better checking later */
statusLabel->setText(tr("Connecting to printer at %1 using FTP")
.arg(printerComboBox->currentText()));
ftp->login();
statusLabel->setText(tr("%1 - Logging in...")
.arg(printerComboBox->currentText()));
/* NEED TO REPLACE THIS WITH THE PROPER FILE OPEN AND SEND */
ftp->list();
statusLabel->setText(tr("%1 - Sending File...")
.arg(printerComboBox->currentText()));
}
void Window::sendFile()
{
cancelButton->setEnabled(true);
ftp = new QFtp(this);
/* This holds the remote server IP Address */
ftp->connectToHost(printerComboBox->currentText());
/* These Status labels are broken they work but show sending file allways, need to do better checking later */
statusLabel->setText(tr("Connecting to printer at %1 using FTP")
.arg(printerComboBox->currentText()));
ftp->login();
statusLabel->setText(tr("%1 - Logging in...")
.arg(printerComboBox->currentText()));
/* NEED TO REPLACE THIS WITH THE PROPER FILE OPEN AND SEND */
ftp->list();
statusLabel->setText(tr("%1 - Sending File...")
.arg(printerComboBox->currentText()));
}
To copy to clipboard, switch view to plain text mode
I put in the "list();" command where the FTP PUT should be to make sure that the QFTP was doing something on the network, which it does. Now i need to actually open the file and send it.
Thanks all, this is my first ... Real (one that does something) QT network APP. Thanks for the assistance.
Bookmarks