PDA

View Full Version : add data to a txt in a url



jantje78
28th April 2011, 10:01
I've made a code that I adds data to test.txt file,
but now I wanna add data to a txt file on a other computer.
To explain further:
I want to add data to my data.txt file which is at url:
http://localhost/project2/data.txt

Can someone help me out? this is the code I have for local adding data(works):


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QTextStream>


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_3_clicked()
{
QFile file("test.txt");
if (!file.open(QIODevice::Append | QIODevice::Text))
return;
QTextStream out(&file);
out << "Group 1\tExcercise 2\tScore 666\tTime 1:45\n\n";
}



Thanks in Advance,
Jantje78.

mcosta
28th April 2011, 11:31
You cannot modify a remote file unless you don't use Network protocols like SMB/NFS that shows remote files as local files.

One solution may be:

Download a copy of remote file
Modifiy the LOCAL file
Upload the modified file on server


this solution is good for a FTS file server.

Other solution may be to use a shared directory on network as a Local Device

jantje78
1st May 2011, 10:46
I was thinking about downloading --> modify --> upload aswell, but I hoped it could be easier...
Well still thanks for your answer, now I dont have to seek further.

jantje78
11th May 2011, 13:09
Can someone help me out? I have read DownloadImageToDisk in index @ qt.
But I still can't find out how to just simply download a .txt file from http://81.205.253.205/project2/test.txt

I know how to modify a tex file but I don't know how to Upload/Download.

Can someone help me out