Uploading files to the FTP server
Since we don't have any files in our FTP directory yet (except the file list), let's write the code to allow us to upload our first file.
- First, open
mainwindow.ui
and right click on theOpen
button. Then, selectGo to slot
and select theclicked()
option:

- A
slot
function will be automatically created for you. Then, add the following code to the function to open up the file selector window for our users to select their desired file for upload:
void MainWindow::on_openButton_clicked() { QString fileName = QFileDialog::getOpenFileName(this, "Select File", qApp->applicationDirPath()); ui->uploadFileInput->setText(fileName); }
- After that, repeat this step and do the same for the
Upload
button. This time, the code for itsslot
function looks something like the following:
void MainWindow::on_uploadButton_clicked() { QFile* file = new QFile(ui->uploadFileInput->text()); QFileInfo fileInfo(*file); uploadFileName = fileInfo.fileName...