CIAO allora Ti ho fatto questo
codice:
PAGINA ASPX
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="upload.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
function popUp(theUrl,theName,props,WinDett)
{
Wopen = window.open(theUrl,theName,props);
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" encType="multipart/form-data" runat="server">
Seleziona file : <input id="File1" type="file" name="File1" runat="server">
Nome File (no path): <input id="Text1" type="text" name="Text1" runat="server">
<asp:label id="lblPreview" style="Z-INDEX: 102; LEFT: 264px; POSITION: absolute; TOP: 176px"
runat="server">Preview</asp:label>
<asp:label id="Label1" style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 112px" runat="server"></asp:label>
<asp:image id="ImgPreview" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 208px"
runat="server"></asp:image><input id="Button1" style="Z-INDEX: 104; LEFT: 328px; POSITION: absolute; TOP: 64px" type="button"
value="Upload" name="Button1" runat="server">
<asp:label id="Label2" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 144px" runat="server"></asp:label>
</form>
</P>
</body>
</HTML>
PAGINA VB CODICE
Imports System.IO
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents File1 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents Text1 As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Button1 As System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents idPreview As System.Web.UI.WebControls.Label
Protected WithEvents ImgPreview As System.Web.UI.WebControls.Image
Protected WithEvents lblPreview As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As String
Response.Write(URL)
End Sub
Sub GeneraTumbnail(ByVal path As String, ByVal img As String, ByVal dimensione As Short, ByVal NameTumb As String)
Dim objImage, objThumbnail As System.Drawing.Image
Dim strFilename As String
Dim nomeFile As String
Dim shtWidth, shtHeight As Short
strFilename = path & img
nomeFile = Request.PhysicalApplicationPath & NameTumb
shtWidth = dimensione
Try
objImage = objImage.FromFile(strFilename)
Catch
Response.Write("Errore Creazione tumb")
End Try
If shtWidth = Nothing Then
shtWidth = objImage.Width
ElseIf Request.QueryString("width") < 1 Then
shtWidth = 100
Else
shtWidth = Request.QueryString("width")
End If
Dim i As Integer
shtHeight = objImage.Height / (objImage.Width / shtWidth)
objThumbnail = objImage.GetThumbnailImage(shtWidth, shtHeight, Nothing, System.IntPtr.Zero)
objThumbnail.GetPixelFormatSize(Imaging.PixelFormat.Extended)
'Tipo di file generato
Response.ContentType = "image/jpeg"
objThumbnail.Save(nomeFile, Imaging.ImageFormat.Jpeg)
ImgPreview.ImageUrl = nomeFile
Label2.Text = "Tumb creata con successo ^_^ in " & nomeFile & ""
objImage.Dispose()
objThumbnail.Dispose()
End Sub
Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
Dim estensione As String
Dim MaxByte As Short
Dim percorso As String
Dim TumbName As String
'set i valori
MaxByte = 1
estensione = ".jpg"
percorso = Request.PhysicalApplicationPath
'Aggiungo al ButtonImage attributo Onclick per visualizzare la popUp
ImgPreview.Attributes.Add("onclick", "popUp( '" & Path.GetFileName(Text1.Value) & estensione & "','imagepopup','toolbar=no,scrollbar=1')")
TumbName = "Tumb" & Path.GetFileName(Text1.Value) & estensione
If Text1.Value = "" Then
Label1.Text = "Attenzione:Devi inserire il nome del file"
Return
End If
If Not IsNothing(File1.PostedFile) Then
Dim filepath As String = Path.Combine(percorso, Path.GetFileName(Text1.Value) & estensione)
Try
File1.PostedFile.SaveAs(filepath)
Label1.Text = "File upload con successo ^_^ in " & filepath & ""
GeneraTumbnail(percorso, Path.GetFileName(Text1.Value) & estensione, MaxByte, TumbName)
Catch Exc As Exception
Label1.Text = "Errore nel salvataggio del file " & filepath & "
" & Exc.ToString()
End Try
End If
End Sub
End Class
QUESTO CODICE CHE FA?
In pratica , UPLOADA Un immagine sul server ti da
a.Percorso dell'immagine originale
b.Percorso dell'immagine Tumb
c.Priview della Tumb
d.Clicchi sulla Tumb e si apre un popUp dell'immagine Originale
Penso che era tutto quello che avevi bisogno fammi sapere