salve a tutti. sto tentando di sviluppare la mia prima applicazione web con ASP.NET. ho appena fiito di leggere il manuale, ed ho pensato di creare un piccolissimo sistema di upload di un file usando il solo file aspx.
il mio codice è questo:
codice:<%@ import namespace="System"%> <%@ import namespace="System.web"%> <%@ import namespace="System.web.UI"%> <%@ import namespace="System.web.UI.WebControls"%> <%@ import namespace="System.web.UI.HtmlControls"%> <%@ import namespace="System.IO"%> <script language="VB" runat="server"> Public Class uploadFile inherits page protected withEvents CmdUpload as button protected lblInfo as Label protected fileInput as htmlInputFile Private sub page_load(sender as object, e as eventArgs) handles MyBase.load fileInput.accept = "image/*" end sub Private Sub CmdUpload_click(sender as object, e as eventArgs) handles CmdUpload.click if fileInput.postedFIle is nothing then lblInfo.text="Specificare file" else try dim serverfilename as string serverFilename=path.getFileName (fileInput.postedFile.FIlename) fileinput.postedFile.saveAs("F:\root\asp.net\"&serverfilename) lblInfo.text="File " & serverfilename & " caricato correttamente" catch err as exception lblInfo.text=err.message end try end if end sub end class </script> <body> <form id="form" runat="server" enctype="multipart/form-data"> <input type="file" id="fileInput" runat="server" /> <input type="submit" id="CmdUpload" value="up" runat="server" /> <asp:label id="lblInfo" runat="server" /> </form> </body>
stranamente accade che non da nessun errore e non carica nessun file.
sapreste illuminarmi? di sicuro ho commesso un errore, ma più che sapere la semplice soluzione mi piacerebbe che qualcuno mi spiegasse il concetto dell'errore.
grazie a tutti.

Rispondi quotando