PDA

Click to See Complete Forum and Search --> : dvst8 with yet another question


dvst8
May 31st, 2000, 12:33 AM
boy, i'm really on a tear here with questions....
it seems i hit hang ups all the time, and reference manuals don't really have info on getting around annoying problems.. for that you have to talk to experienced programmers... so here I am, pleading for knowledge...
i only hope i can help others, as much as you guys have helped me..

anyway, on with the question:

I tried to build a simple image broswer in ASP, but couldn't get it working because of a silly detail which I can't work around.

I have a <input type = "file" name = "file1"> field in a form, and I want to make it so that when the user has browsed and located his/her image, the image will be displayed for him on the same page.

I had made a "View" (which was really a type = "submit" button) button beside the file field, and when the user clicked it, the page resubmitted the form to the same page, except this time displaying the specified image.

HOWEVER, then the page reloads the file field comes up blank. Sure I could capture it from the form, but you CANNOT do the following:


<input type = "file" name = "file1" value = "<%=Request.form("file1")%>">


The value will not fill in!!!!! This is by design in HTML spec. You are not allowed to specify the value of a file field.

See my problem?
It's no good having this simple image browser, if when the page reloads, the image comes up, but not the path to the file....

This is very annoying, and I need a work-around!

tx
d8

[Edited by dvst8 on 05-31-2000 at 01:35 PM]

May 31st, 2000, 06:11 AM
this will allow a user to browse images on their own machine:

<%@ Language=VBScript %>
<HTML><BODY>
<%
dim strLocalImageLocation
strLocalImageLocation = Trim(Request("ImageFile"))
%>

<form name="test" method="post" action="ImageBrowser.asp">
<input type="file" name="ImageFile" value="">
<input type="submit" value="Show Image">
</form><br>
<%
if strLocalImageLocation <> "" then
%>
<img src="<%= strLocalImageLocation %>">
<%
end if
%>

</BODY>
</HTML>

dvst8
May 31st, 2000, 08:25 PM
thanks for the code pvb. works flawlessly.
i had come up with something very similar myself...

But does anyone know of a way to have the following happen:
When the page is resubmitted to itself (to view the image), I need the file field to be filled in with the path to file... Tough one.

I really do not think it can be done.