0

Web サイトへのファイルのアップロードをシミュレートしようとしています。次のようなhtmlフォームがあります。

<input name="upl" type="file" style="width:266px" value="File" id="file_input_box" onchange="AFUpload.ad_placement(this.form.upl, 5242880)">

また

<input type="file" name="file" onchange="StartUpload(this.form, this.form.file.value)" size="40" style="margin-top:5px;">

このオープン標準の「ファイルを開くダイアログ ボックス」は、ファイル (この場合は画像) をアップロードするためのものです。画像をアップロードしたいのですが、ボタンをクリックするのではありません。

これは近いですか、それとも単にばかですか?

void Set(string tagname, string attribute, string attName, string value)
        {

            HtmlElementCollection tagsCollection = webBrowser1.Document.GetElementsByTagName(tagname);

            foreach (HtmlElement currentTag in tagsCollection)
            {

                if (currentTag.GetAttribute(attribute).Equals(attName))

                    currentTag.SetAttribute("value", value);
            }
        }


Set("input", "name", "upl", @"C:\image.jpg");
4

0 に答える 0