webForumDet fria alternativet

file upload fungerar ej efter säkerhetspatch?

6 svar · 412 visningar · startad av kolas

kolasMedlem sedan mars 2001142 inlägg
#1

Jag använder ett "webbhotell" där jag har en vad jag tycker borde vara en simpel filuppladdningsfunktion. Det har fungerat i ett par månader utan problem och nu så fungerar det inte längre, det enda som "webbhotellet" säger är att de har uppdaterat säkerhetspatchar från Microsoft.

Är det något som ser fel ut i denna kod, jag är tyvärr nybörjare på ASP.NET...

   <script language="VB" runat=server>
       Sub DoUpload(Sender As Object, e As System.EventArgs)
          Dim sPath as String
          Dim sFile as String
          Dim sFullPath as String
          Dim sSplit() as String
          Dim sPathFriendly as String
          
          'Upload to same path as script
          'Internet Anonymous User must have write permissions
          
          sPath = Server.MapPath(".")
         If Right(sPath, 1) <> "\" then 
			sPathFriendly = sPath 'Friendly path name for display
			sPath = sPath & "\media\"
		Else
			sPathFriendly = Left(sPath, Len(sPath) - 1)
		End If
			
          
          'Save as same file name being posted
          'The code below resolves the file name
          '(removes path info)
          sFile = txtUpload.PostedFile.FileName
          sSplit = Split(sFile, "\")
          sFile = sSplit(Ubound(sSplit))
          
          
          
          sFullPath = sPath & sFile
		  Try
          txtUpload.PostedFile.SaveAs(sFullPath)
         lblResults.Text = "Upload of File " & sFile & " succeeded. Please close this window"
         
         Catch Ex as Exception
			
			lblResults.Text = "Upload of File " & sFile & " to " & sPathFriendly & " failed for the following reason: " & Ex.Message
         Finally
			lblResults.Font.Bold = True
			lblResults.Visible = true
         End Try
		
       End Sub

    </script>
<html>
    <body>
      <form enctype="multipart/form-data" runat=server>
           Select File To Upload:
           <input id="txtUpload" type=file runat=server>
		   <br />
		   <asp:button id=btnUpload Text="Upload File" OnClick="DoUpload" runat=server/>
          <hr noshade>
          <asp:label id="lblResults" Visible=false runat=server/>
     </form>
   </body>
</html>
emissionMedlem sedan dec. 19996 721 inlägg
#2

Felmeddelande?

kolasMedlem sedan mars 2001142 inlägg
#3

emission skrev:

Felmeddelande?

Tyvärr är felmeddelanden avstängda så det enda jag ser är den där standardtexten:

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
emissionMedlem sedan dec. 19996 721 inlägg
#4

Sätt då <customErrors mode="Off"

kolasMedlem sedan mars 2001142 inlägg
#5

emission skrev:

Sätt då <customErrors mode="Off"

Nu är jag inte med på hur du menar...

PMedlem sedan jan. 20012 204 inlägg
#6
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
emissionMedlem sedan dec. 19996 721 inlägg
#7

i web.config alltså...

129 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
127 ms — hämta tråd, inlägg och bilagor (db)