Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 18
  1. #1

    il resize nn va, perche?

    ragazzi mi aiutate a trovare l'errore in questo script?
    esegue correttamente l'upload sul server ma nn fa il resize dell'immagine..

    posto le due pagine...

    UPLOADFOTO.ASP

    [CODE
    <%

    Function RedimFoto(nomeFoto,sizeThumb,sizeFoto)
    Dim xml,tmpResult,url
    Set xml = Server.CreateObject("Microsoft.Xmlhttp")
    URL = "http://www.scibettabbigliamento.it/ridimensiona.aspx?foto=" & nomeFoto & "&sizeThumb=" & sizeThumb & "&sizeFoto=" & sizeFoto
    xml.open "GET", URL ,false
    xml.send()
    tmpResult = xml.ResponseText
    Set xml = nothing
    if Instr(1,tmpResult,"Errore") <> 0 then
    'Il ridimensionamento non è andato a buon fine
    RedimFoto = false
    else
    RedimFoto = true
    end if
    End Function

    connessione = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("mdb-database/dbbase.mdb")
    dominio = "http://www.scibettabbigliamento.it/"
    Set Fso = Server.CreateObject("Scripting.FileSystemObject")

    Dim oUpload
    newRecord = false
    Set oUpload = new cUpload
    With oUpload
    .EnabledAspUpload = False
    .EnabledImageSize = true
    .EnabledLog = False
    .AutoRename = False
    .Overwrite = False
    .SetPath "Vetrine/"
    .Load()
    'Recupero la chiave che mi verra' passata o via querystring (si presuppone da una lista)
    if Request.QueryString("keyFoto") <> "" then
    keyFoto = Request.QueryString("keyFoto")
    else
    'Oppure nel caso sia submitato il form mi proviene dal campo hidden
    if .Form("keyFoto") <> "" then
    keyFoto = .Form("keyFoto")
    else
    keyFoto = 0
    end if
    end if
    set Connection = server.CreateObject("Adodb.Connection")
    connection.open connessione
    set Rs = Server.CreateObject("ADODB.Recordset")
    Sql = "SELECT * FROM center where idcenter=" & keyFoto
    Rs.Open Sql, connection,3,3
    if Rs.eof then
    Rs.addnew
    newRecord = true
    else
    keyFoto = Rs("idcenter")
    categoria = Rs("categoria")
    foto = Rs("file")
    end if
    'Se è stato submittato il form eseguo l'update del record
    if .Form("action") <> "" then
    .movefirst()
    Rs("categoria") = .Form("categoria")
    rs("file") = "Vetrine/" & .Files("Name") & "." & .Files("Ext")
    Rs.update
    'Pesco la chiave in modo da aggiungerla in testa all'immagine per avere un
    'nome univoco
    UltimoId = Rs("idcenter")
    While Not .Files.EOF
    if .Files("inputName") = "imgUpload" then
    'Compongo il nome
    nomeFoto= .Files("Name") & "." & .Files("Ext")
    'Salvo il file
    .SaveAs nomeFoto

    end if
    .Files.MoveNext
    Wend
    'Eseguo il ridimensionamento e la funzione restituisce true se tutto è
    'andato a buon fine
    if RedimFoto(nomeFoto,100,600) then
    Rs("file") = "Vetrine/" & nomeFoto
    'Cancello quella originale uploadata
    'Nota che il file ridimensiona.aspx è configurato in maniera tale
    'che se il file di origine ed il file di destinazione sono identici anche nel
    'percorso, il file viene ridimensionato su se stesso e quindi
    'l'operazione di cancellazione del file originale NON DEVE essere fatta
    'Fso.DeleteFile Server.MapPath("foto/" & nomeFoto)
    Rs.update
    else
    errUpload = "Errore nel ridimensionamento delle foto"
    end if
    end if
    end with
    if newRecord then Rs.CancelUpdate
    Rs.Close
    Connection.Close
    Set Connection = nothing
    Set Rs = nothing
    Set Fso = nothing
    %>

    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="testUpload" method="post" enctype="multipart/form-data" action="uploadFoto.asp">
    <% if errUpload <> "" then Response.Write("<h1>" & errUpload & "</h1>") %>


    Categoria Foto:
    <input name="categoria" type="radio" value="u">
    Uomo
    <input name="categoria" type="radio" value="d">
    Donna
    <input name="categoria" type="radio" value="a">
    Accessori

    File: <input type="file" name="imgUpload">

    <input type="submit" name="action" value="conferma">
    <% if nomeFoto <> "" then %>
    <hr>
    Foto precedentemente caricate


    piccola:

    [img]Vetrine/centre_flash/<%=nomeFoto%>[/img]
    <% end if %>
    <input type="hidden" name="keyFoto" value="<%=keyFoto%>">
    </form>

    </body>
    </html>[/CODE]



    RIDIMENZIONA.ASPX

    codice:
    <%@ Page Language="VB" ContentType="text/html"%>
    <script language="vb" runat="server">
         Sub Page_Load(Server as Object,e as System.EventArgs)
              Dim redimFoto as String      = Request.Querystring("foto")
              Dim RedimSizeThumb as integer = CInt(Request.QueryString("sizeThumb"))
              Dim RedimSizeFoto as integer = CInt(Request.QueryString("sizeFoto"))
              ReDimImg("Vetrine/" & redimFoto ,"Vetrine/centre_flash/" & RedimFoto,RedimSizeThumb,0)
              ReDimImg("Vetrine/" & redimFoto ,"Vetrine/centre_flash/" & RedimFoto,RedimSizeFoto,0) 
         End Sub
         Public Sub ReDimImg(SourcePath as String,ResizeName as string, width as integer,height as integer) 
              Try
                   'Creo l'oggetto di riferimento al file originale
                   Dim TmpBmp as System.Drawing.Bitmap     = CType(System.Drawing.Image.FromFile(Server.MapPath(SourcePath)), System.Drawing.Bitmap) 
                   Dim newWidth,newHeight as string
                   'Se il parametro height è lasciato a 0 costruisco il with in maniera proporzionata
                   if height = 0 Then 
                        newHeight                = Convert.ToInt32(width / TmpBmp.Width * TmpBmp.Height)
                   else 
                        newHeight                = height
                   End if 
                   'Se il parametro with è lasciato a 0 costruisco l'height in maniera proporzionata
                   if width = 0 Then 
                        newWidth                = Convert.ToInt32(height / TmpBmp.Height * TmpBmp.Width) 
                   else
                        newWidth                = width
                   end if 
                   'Creo la miniatura con lunghezza e larghezza elaborati 
                   Dim miniaturabmp as      New System.Drawing.Bitmap(TmpBmp, newWidth, newHeight)
                   'Distruggo l'oggetto dell'immagine originale che non mi serve +
                   TmpBmp.Dispose() 
                   'controllo l'estensione e salvo la miniatura nel giusto formato 
                   if SourcePath.toLower().EndsWith(".jpg") or SourcePath.toLower().EndsWith(".jpeg") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Jpeg) 
                   elseif SourcePath.toLower().EndsWith(".gif") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Gif) 
                   elseif SourcePath.toLower().EndsWith(".png") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Png) 
    				elseif SourcePath.toLower().EndsWith(".tiff") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.tiff) 
                   else
                        Response.Write("Errore Formato")
                        'Si puo' ampliare l'elseif in questo modo:
                        'elseif SourcePath.toLower().EndsWith(".[Estensione]") Then 
                        'miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.[Estensione]) 
                        'dove [Estensione] puo essere Bmp, Emf, Exif, Tiff, Wmf
                   end if 
                   miniaturabmp.Dispose() 
                   Catch ex as System.Exception 
                        'Nel caso stampo l'errore:
                        Response.Write("<hr>Errore nel ridimensionamento dell'immagine:
    " & ex.Message & "
    
    ")
                        Response.Write("
    " & ex.StackTrace & "<hr>") 
              End Try
              Response.Write("Ridimensionamento effettuato con successo")
         End Sub 
    </script>
    GRAZIE

  2. #2
    non c'è nessuno che mi puo' dare una mano?

  3. #3
    dai ragazzi..........

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    prova ad avviare direttamente la pagina ridemnsiona.aspx?foto=indirizzo_foto.ext e scriverci che errore viene..

  5. #5
    ecco l'errore

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Runtime Error
    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".




    <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.




    <configuration>
    <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
    </configuration>

  6. #6
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    crea un file web.config e mettici
    <configuration>
    <system.web>
    <customErrors mode="Off"/>
    </system.web>
    </configuration>
    e mettilo nella root del sito

    poi sostituisci la 1^ riga della pag ridimensiona.aspx con
    codice:
    <%@ Page Language="VB" ContentType="text/html" Debug = "True"%>
    e scrivi l'errore che ti viene..

  7. #7

  8. #8
    l'errore è uguale a quello di prima...
    pur avendo messo nella root del sito il file "web.config"
    e cambiato la prima riga

    ecco l'errore

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Runtime Error
    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".




    <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.




    <configuration>
    <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
    </configuration>

  9. #9

  10. #10
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    Originariamente inviato da pieromt
    SMS, ci sei?
    non è che vivo qua dentro?
    prova a mettere il web.config nella stessa cartella della pagina..

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.