You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "christiansson" is male
  • "christiansson" started this thread

Posts: 2

Location: Graz, Austria

  • Send private message

1

Sunday, April 11th 2004, 10:17pm

download a file from server!

Hi!

i have a problem i want to download a file from a server and i use this code:

QString localfilename("test.exe");
qInitNetworkProtocols();
QUrlOperator op;
op.copy(QString("http://home.pages.at/openminded/test.exe"), localfilename);

the network status shows me that it is working, but i have no file named test.exe in the directory on my hd...

i already tried this:

QHttp http;
http.setHost("http://home.pages.at/openminded");
http.get("index.html", &file);

this does also not work ....

thank you for any idea!

ciao
christiansson

Christian

Unregistered

2

Sunday, April 11th 2004, 10:53pm

Hi,

I have written this little testapp a few days ago...

have fun
Christian has attached the following file:
  • tar.tar.gz (2.17 kB - 155 times downloaded - latest: Jun 18th 2012, 11:01am)

3

Wednesday, June 1st 2005, 2:56pm

Hello Christian,

I have used your test application to write a code to download a file from a web server. It is working fine thanks.
Now I would to write a code to upload a file to a web server.

I have modified your code as follows:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void MainForm::getFile() 
{
 fileGet->setName("Basistank.sldprt"); // A local existing file
 fileGet->open(IO_ReadOnly);
 httpGet->setHost("192.168.0.6");
 QString error = httpGet->errorString();
 httpGet->post("/Basistank.sldprt", fileGet);
 httpGet->closeConnection();
}
void MainForm::httpDone( bool error ) {
 if(error) {
  QString error = httpGet->errorString();
 }
 fileGet->close();
}


I have an error in httpDone: "Server closed connection unexpectedly".

Do you think this is wrong with my code?

Regards,

Jean-louis