Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner


Allows uploads of only jpg files


<html>
<head>
<script language="VB" runat="server">
Sub Upload(Source As Object, e As EventArgs)
  If Not (myFile.PostedFile Is Nothing) Then
    Dim intFileLength as Integer
    Dim ImgFileNamePath as String
    Dim ImgFileName as String
    if myFile.PostedFile.ContentType <> "image/pjpeg" then
      lbResult.Text = "Tipo di file non valido"
    else
      if myFile.PostedFile.ContentLength > 50000 then
        lbResult.Text = "File troppo grande"
      else
        try
          ImgFileNamePath = myFile.PostedFile.FileName
          intFileLength = Instr(1, StrReverse(ImgFileNamePath), "\")
          ImgFileName = Mid(ImgFileNamePath, (Len(ImgFileNamePath)-intFileLength)+2)
          myFile.PostedFile.SaveAs("c:\wwwroot\sito\immagini\" & ImgFileName)
          lbResult.Text = "File salvato"
        catch ex As Exception
          lbResult.Text = "Errore nel salvataggio:<br>" & ex.Message
        end try
      End If
    End If
  End If
End Sub
</script>
</head>
<body>
<form name="Form1" runat="server">
<INPUT id="myFile" type="file" name="myFile" runat="server"><BR>
<INPUT id="Button1" type="button" value="Upload" name="Button1" runat="server" OnServerClick="Upload"><BR><BR>
<asp:Label ID="lbResult" Runat="server"></asp:Label>
</form>
</body>
</html>



Download Code...


Print Page


 








Page top

risorse per webmaster