Forums
This topic is locked
Help with asp.net upload
Posted 07 Jan 2003 16:44:07
1
has voted
07 Jan 2003 16:44:07 paul durbar posted:
Cant get the asp.net upload extension working as all, tried everything, the following code produces the error:Compiler Error Message: BC30451: Name 'file' is not declared.
Source Error:
Line 14: >
Line 15: <Parameters>
Line 16: <Parameter Name="@drawingfilename" Value='<%# IIf((file.PostedFile.FileName <> Nothing), GetFileNameFromPath(file.PostedFile.FileName), ""

Line 17: </MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert>
Line 18: <MM

Source File: C:\Inetpub\wwwroot\aspxupload\TMPc7mu88cp1e.aspx Line: 16
<b>The page code is:</b>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='<%# "INSERT INTO uploads (drawingfilename) VALUES (?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_uploadconn"

DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_uploadconn"

Expression='<%# Request.Form("MM_insert"

CreateDataSet="false"
SuccessURL='<%# "uploaddone.aspx" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@drawingfilename" Value='<%# IIf((file.PostedFile.FileName <> Nothing), GetFileNameFromPath(file.PostedFile.FileName), ""

</MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert>
<MM

id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_uploadconn"

DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_uploadconn"

CommandText='<%# "SELECT * FROM uploads" %>'
Debug="true"
></MM

<MM<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>ageBind runat="server" PostBackBind="true" />
<script language="vb" runat="server">
' ===============================================================================
' WWWeb Concepts ASP.NET Development Solutions www.ebconcepts.com
' Copyright 2002. All Rights Reserved. Get file from form1
' ===============================================================================
Function GetFileNameFromPath(ByVal PathName As String)
Dim intFirstPos As Integer
intFirstPos=InStrRev(PathName, "\"

GetFileNameFromPath = Mid(PathName, intFirstPos)
End Function
Sub Page_UnLoad(Source As Object, E As EventArgs)
If Page.IsPostBack then
Dim strSavePath As String
Dim strFileName As String
strFileName=GetFileNameFromPath(file.PostedFile.FileName)
strSavePath =Server.MapPath("uploads"

If(file.PostedFile.FileName <> Nothing) then
file.PostedFile.SaveAs(strSavePath & "\" & strFileName)
end if
end if
End Sub
</script>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form runat="server" action="" method="post" enctype="multipart/form-data" name="form1">
<p>
<input type="file" name="file">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
Anyone any ideas, im stuck here????