Link to home
Create AccountLog in
Avatar of trims30
trims30

asked on

How to Preset Value for Input Type=File

Am using IE8 or FireFox 18.0.2 and want to use ASP File Upload but am unable to programatically set value for Input Type=File. (xtfilename) in example below.

I'm using this to upload a program generated file.  I can use Browse Button to select file and my program works but would like to preset file name in the input field rather than have user hunt for file.

Tried passing file name using POST as in the following example.

 
<%
dim xtfilename
xtfilename=Request.QueryString("tFN")
%>

<form name="file_upload" method="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">

<Div ID=files>
   <input type="File" name="File1" size="60" value="<%=xtfilename%>"><br>
   <input type="hidden" name="email" size="60" value="<%=tMailto%>">
   <br>
</Div>

<input Name=SubmitButton Value="Upload" Type=Submit><br>
</Form>

Open in new window


Also tried VB code to open the form in a webbrowser then using the browser document property to set value into xtfilename.

    WebBrowser1.Document.file_upload.xtfilename.Value = "C:\SomeFileName"

No luck so far.

Could use some help on this.

Thanks,

Lee
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of trims30
trims30

ASKER

Shaun:
Prior to IE8 we were able to programatically PASTE into a File Type field but IE8 stopped that.

Trying to automate posting of c:\users\sam\appdata\local\tmp\012345678.zip into the file field rather than asking someone to browse for the file.

Since IE8 I've put a message on the page telling them to click BROWSE and find file c:\users\sam\appdata\local\tmp\012345678.zip then click Submit.  People are not paying attention where they're browsing and are uploading wrong files.

Any solutions you could recommend??

Lee
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Your options are limited. An ActiveX control can interact with the local PC's file system and Java Applets can. Other options exist as well but they generally require installing software on the user's PC.
Avatar of trims30

ASKER

Scrapped it out and am writing FTP procedure .
Will Split points today

Thanks.

Lee