Tutorial :How to upload file with form-post using c++ Qt-WebKit?


So, when i was dealing with forms before what i would do is find web element that is part of the form input, set value of that form input by element.setattribute("value", "infoi want to add")

then simply when i set value of form elements i click submit button of form.

Is this possible to do with web-form input type="file" and how can i do it?



The simplest and the most straightforward way to do exactly what you've described is to get form's target address with QWebFrame::hitTestContent and then to post a file with QNetworkAccessManager::post. You also could inject some javascript code into a loaded page (see this for more details), but that would be an overkill for such a simple taks. And besides in the latter case all your injected javascript will be gone after submitting the form (i.e. after the page is reloaded).

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »