There is a file upload form:

<input class="file" id='textinput' type=file name=uploads_0 id=attachId0 size=60 onchange="checkUploadFile(this);" style="width: 479px"> 

I want to send my file: I find the item I need by type and change the value:

 for i:=0 to WebBrowser1.OleObject.Document.forms.Length -1 do begin FormItem:=WebBrowser1.OleObject.Document.forms.Item(i); for j:=0 to FormItem.Length -1 do if FormItem.Item(j).type ='file' then FormItem.Item(j).filename:='D:\1.jpg'; end; 

But nothing happens, unlike the usual " input type=text ". Why?

Maybe there are other ways to upload files?

    1 answer 1

    This is one of the aspects of browser protection of personal data. Imagine a situation in which JavaScript of any site could automatically fill in such input-s and upload them to a server. And in the files, for example, the keys to the webmoney! TWebBrowser c HTML works through DOM (as well as JavaScript). Therefore, nothing happens.

    It makes sense to dig in the direction of direct sending a post-request with a file to the server.

    • I didn’t quite understand where the protection was, if I work from a browser, and not a script on another site - Antiless
    • However, @KiTE is right) It is simply forbidden to manually change the value of <input type="file" /> , no matter what. - Sh4dow
    • Clearly, I will shaman with clicks. - Antiless
    • Better manual POST, really. More reliable. - Sh4dow
    • then you need to track all the parameters: cookies, hidden fields, and so on. no, I will directly do as usual (: - Antiless