Hey guys,
I've got an ASP.NET upload form on one page, where the user can upload an image. heres the code for that one:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<html>
<head>
<script language="VB" runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
If imageupload1.HasFile Then
imageupload1.SaveAs(Server.MapPath(".") + "/uploadedimages/" & imageupload1.FileName)
Label1.Text = "Received " & imageupload1.FileName & " Content Type " & imageupload1.PostedFile.ContentType & " Length " & imageupload1.PostedFile.ContentLength
Else
Label1.Text = "No uploaded file"
End If
end sub
</script>
</head>
<body>
<form id="imguplad" runat=server>
<asp:FileUpLoad id="imageupload1" AlternateText="You cannot upload files" runat="server" />
<asp:Button id="Button1" Text="Upload" OnClick="Button1_Click" runat="server" />
<asp:Label id="Label1" runat="server" />
<input type="button" value="Click here when image is uploaded"
onClick="location.href='imageloadtest.aspx';">
</form>
</body>
</html>
Then I am trying to retrieve it on another page, using the following code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
...blah
<body>
<img id="image" src="Server.MapPath(".")+"/uploadedimages/"+Request.Form["imageupload1.FileName"]";">
</body>
...blah
Can't seem to get it to show up? I must have some path slightly wrong. Any ideas?
Thanks
EDIT: By the way, the image uploads perfectly, it just won't show up on the next page.