You are not logged in.

Dear visitor, welcome to KDE-Forum.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.

borker

Beginner

  • "borker" started this thread

Posts: 3

Location: Toronto

Occupation: Developer

  • Send private message

1

Saturday, May 28th 2005, 2:54pm

KIO::http_post file upload

HI there all, I'm hoping someone can give me some pointers on how to transfer a file via the KIO::http_post method. I have the following code:

Source code

1
2
3
4
5
6
7
8
static char bindata[] = "uname='fred'&password='secret'";
QByteArray postByteData;
postByteData.setRawData(bindata, sizeof(bindata) );
				
KURL dest_URL = KURL("http://www.target.com/upload.php");
            
KIO::TransferJob* job = KIO::http_post( dest_URL, postByteData, false ); // return * KIO::Transfer
job->addMetaData("content-type:", "Content-Type: application/x-www-form-urlencoded" );


and what I want to do is also include an image file. Presumably I need to set an appropraite mime type, I'm just not sure which one and then how to encode and include the file. I havent had much luck finding documentation on how browsers normally encode this when files are POSTed using the

Source code

1
<input type='file'>
tag and I'm not sure how I would achive this using http_post.

Has anyone done something similar and could give me a few pointers?

borker

Beginner

  • "borker" started this thread

Posts: 3

Location: Toronto

Occupation: Developer

  • Send private message

2

Wednesday, June 1st 2005, 4:52am

RE: KIO::http_post file upload

this is the only thing thats holding me back on finishing up my application... can anyone point me in the right direction?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

3

Wednesday, June 1st 2005, 1:50pm

Hmm, sorry, no idea.

You could try asking on kde-devel or kfm-devel mailinglists

Cheers,
_
Qt/KDE Developer
Debian User

borker

Beginner

  • "borker" started this thread

Posts: 3

Location: Toronto

Occupation: Developer

  • Send private message

4

Wednesday, June 1st 2005, 10:45pm

thanks for the reply, I think that the mailing lists will be my next step, or i'll just bight the bullet and spend some time experimenting.

From the source code for http_post it just looks like it streams what ever is in the byte array passed to it out over the network so i guess the issue here is more of an HTTP one than a strictly KDE one. I was just hoping someone else had already done the leg work on this and could clue me in...