ho un problema con lo script per uplodare file
praticamente ho ricopiato lo scrip suggerito da nazzareno:
C:\varie\UploadASP_NET\ASPAlliance_com The #1 ASP_NET Developer Community ASP _NET Tutorial.htm
testando lo script in debug mi sono accorto che non entra
nel blocco if:
if not(MyFile.PostedFile is nothing) then.....
in quanto MyFile.PostedFile è sempre nothing
qualcuno puo aiutarmi
posto il codice completo
(spero che la formattazione non sia andata a farsi friggere)
grazie a tutti
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="prova.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="vb" runat="server">
sub Upload(source as object,e as EventArgs)
if not(MyFile.PostedFile is nothing) then
_
_Dim intFileNameLength as Integer
_Dim strFileNamePath as String
_Dim strFileNameOnly as String
strFilenamePath = MyFile.PostedFile.FileName
intFileNameLength = instr(1,StrReverse(strFileNamePath),"/")
strFileNameOnly = Mid(strFileNamePath,(len(strFileNamePath)-intFileNameLength)+2)
MyFile.PostedFile.SaveAs("c:\inetpub\wwwroot\prova \foto\" & strFileNameOnly)
lblMessaggio.text = "File Uplodato correttamente"
end if
end sub
</script>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" type="file" id="MyFile" runat="server">
<INPUT id="Button1" style="Z-INDEX: 102; LEFT: 10px; WIDTH: 233px; POSITION: absolute; TOP: 49px; HEIGHT: 25px" type="button" value="Upload" name="Button1" onserverclick="Upload" runat="server">
<asp:Label id="lblMessaggio" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 97px" runat="server" Width="558px" Height="68px" ForeColor="#00C000" Font-Size="XX-Large" />
</form>
</body>
</HTML>