Ragazzi sto impazzendo su un pezzo di codice che mi fa sclerare perchè in locale mi funziona e sul server no preciso che il server è aruba:
potete dargli un okcchiata se volete
qui
codice:
Imports System
Imports System.IO
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Drawing.Image
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Codice generato da Progettazione Web Form "
'Chiamata richiesta da Progettazione Web Form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents File1 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents ImageButton1 As System.Web.UI.WebControls.ImageButton
'NOTA: la seguente dichiarazione è richiesta da Progettazione Web Form.
'Non spostarla o rimuoverla.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: questa chiamata al metodo è richiesta da Progettazione Web Form.
'Non modificarla nell'editor del codice.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Inserire qui il codice utente necessario per inizializzare la pagina
End Sub
Dim filename As String
Dim estensione As String
Public Sub Insert()
Dim foto As String = "public/pictprod/"
Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("mdb-database/lbj.mdb") & ";"
Dim sql As String = "insert into pictures (idarticolo,pathfoto) values (" & Trim(Request.QueryString("idart")) & ",'" & foto & filename & "')"
Dim conn As New OleDbConnection(connstr)
Dim commandsql As New OleDbCommand(sql, conn)
conn.Open()
commandsql.ExecuteNonQuery()
' Response.Write(sql)
conn.Close()
End Sub
Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
filename = File1.PostedFile.FileName
estensione = System.IO.Path.GetExtension(filename)
Dim arrfilename As Array = Split(filename, "\")
filename = arrfilename(UBound(arrfilename))
filename = Trim(Request.QueryString("idart")) & estensione
Dim foto As Bitmap
Dim thumb As Image
Dim path2 As String = (Server.MapPath("public/pictprod/" & filename))
Dim path As String = (Server.MapPath("public/pictprod/" & "t_" & filename))
foto = New Bitmap(File1.PostedFile.FileName)
Call redims(foto, 100, 75, foto.Height, foto.Width, path)
Call redims(foto, 240, 180, foto.Height, foto.Width, path2)
Call Insert()
Response.Write("immagine uploadta")
Page.RegisterStartupScript("alert", "<script>window.opener.document.ref.submit();window.close();</script>")
End Sub
Sub redims(ByVal objfoto As Bitmap, ByVal StandardHeight As Integer, ByVal StandardWidth As Integer, ByVal altezza As Integer, ByVal larghezza As Integer, ByVal percorso As String)
If altezza > StandardHeight Or larghezza > StandardWidth Then
Dim PercDiffW As Integer = CLng((StandardHeight * 100) / altezza)
Dim PercDiffH As Integer = CLng((StandardWidth * 100) / larghezza)
Dim PercDiff As Integer = PercDiffH : If PercDiffW < PercDiffH Then PercDiff = PercDiffW
StandardWidth = (larghezza / 100) * PercDiff
StandardHeight = (altezza / 100) * PercDiff
Else
StandardHeight = altezza
StandardWidth = larghezza
End If
Dim thumbnails As Image = objfoto.GetThumbnailImage(StandardWidth, StandardHeight, Nothing, IntPtr.Zero)
thumbnails.Save(percorso)
End Sub
End Class