Sent the data instead of relying on the "submit" button of the html

  • snippet of the website

    <form action="index.php" method="post" enctype="multipart/form-data" >
    <td><input type="file" name="upfile" size="35" /></td>
    <td><input type="submit" value="send" /></td>


    I want to select and send some files onto a server without manually click on
    the "file" and "send" button.Is this possible?


  • Thanks, looks like this is what I need.

  • Do some test and stuck, don't understand how to use it properly

    "The website I want to post":

    The html I think it is related to my objective

    <td><input type="text" name="sub" size="35">
    <input type="submit" value="送信する" /></td>

    <td><textarea name="com" cols="48" rows="4" wrap=soft></textarea></td>

    class postToKomica : public QObject

    void sendTextToKomica()
    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

        //set the text?
        QHttpPart textPart;
        textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
        textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"com\""));
        textPart.setBody("this is a good animation");
        //"click" the submit button?
        QHttpPart sendPart;
        sendPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"submit\""));
        QUrl url("");
        QNetworkRequest request(url);
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        QNetworkReply *reply = manager->post(request, multiPart);
        multiPart->setParent(reply); // delete the multiPart with the reply
        connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));

    private slots:
    void finished(QNetworkReply *reply)
    qDebug() << reply->error();


    The reply is "0".
    I only know some basic about html,javascript and network
    What do I need to know before I can "post" the data onto
    the website with the help of QHttpMultiPart and QHttpPart?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.