Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 24
  1. #1
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177

    Upload di più immagini

    Ciao a tutti, so che ne avete già straparlato ma io devo risolvere un problema che richiede la vostra abilità. Devo fare un catalogo prodotti ed ho recuperato un Upload ed un form che funzionano perfettamente, l'unica cosa è che manca la possibilità di fare il thumbnail, quindi pensavo si ampliare lo stato attuale del form condentendogli l'upload di 2 imm il thumbnail e il dettaglio, memorizzando i dati nel db. Le ho provate tutte ma sono una schiappa come posso affrontare questo problema?

    Vi allego il cod della upload e del form:
    <%
    Class FileUploader
    Public Files
    Private mcolFormElem

    Private Sub Class_Initialize()
    Set Files = Server.CreateObject("Scripting.Dictionary")
    Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
    End Sub

    Private Sub Class_Terminate()
    If IsObject(Files) Then
    Files.RemoveAll()
    Set Files = Nothing
    End If
    If IsObject(mcolFormElem) Then
    mcolFormElem.RemoveAll()
    Set mcolFormElem = Nothing
    End If
    End Sub

    Public Property Get Form(sIndex)
    Form = ""
    If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
    End Property

    Public Default Sub Upload()
    Dim biData, sInputName
    Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
    Dim nPosFile, nPosBound

    biData = Request.BinaryRead(Request.TotalBytes)
    nPosBegin = 1
    nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))

    If (nPosEnd-nPosBegin) <= 0 Then Exit Sub

    vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
    nDataBoundPos = InstrB(1, biData, vDataBounds)

    Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))

    nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
    nPos = InstrB(nPos, biData, CByteString("name="))
    nPosBegin = nPos + 6
    nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
    sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
    nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
    nPosBound = InstrB(nPosEnd, biData, vDataBounds)

    If nPosFile <> 0 And nPosFile < nPosBound Then
    Dim oUploadFile, sFileName
    Set oUploadFile = New UploadedFile

    nPosBegin = nPosFile + 10
    nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
    sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
    oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))

    nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
    nPosBegin = nPos + 14
    nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))

    oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))

    nPosBegin = nPosEnd+4
    nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
    oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)

    If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
    Else
    nPos = InstrB(nPos, biData, CByteString(Chr(13)))
    nPosBegin = nPos + 4
    nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
    If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
    End If

    nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
    Loop
    End Sub

    'String to byte string conversion
    Private Function CByteString(sString)
    Dim nIndex
    For nIndex = 1 to Len(sString)
    CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
    Next
    End Function

    'Byte string to string conversion
    Private Function CWideString(bsString)
    Dim nIndex
    CWideString =""
    For nIndex = 1 to LenB(bsString)
    CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
    Next
    End Function
    End Class

    Class UploadedFile
    Public ContentType
    Public FileName
    Public FileData

    Public Property Get FileSize()
    FileSize = LenB(FileData)
    End Property

    Public Sub SaveToDisk(sPath)
    Dim oFS, oFile
    Dim nIndex

    If sPath = "" Or FileName = "" Then Exit Sub
    If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

    Set oFS = Server.CreateObject("Scripting.FileSystemObject")
    If Not oFS.FolderExists(sPath) Then Exit Sub

    Set oFile = oFS.CreateTextFile(sPath & FileName, True)

    For nIndex = 1 to LenB(FileData)
    oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
    Next

    oFile.Close
    End Sub

    Public Sub SaveToDatabase(ByRef oField)
    If LenB(FileData) = 0 Then Exit Sub

    If IsObject(oField) Then
    oField.AppendChunk FileData
    End If
    End Sub

    End Class
    %>




    Form

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%if not session("AdminOk")="true" then response.Redirect "login.asp" %>



    <%
    dim productname
    dim category
    dim details
    dim filename
    dim filenamedett
    dim msg
    Set Uploader = New FileUploader
    Uploader.Upload()


    if Uploader.Form("submit")<>"" then
    productname = Uploader.Form("name")
    category = Uploader.Form("Category")
    details = Uploader.Form("details")
    call SaveRecord()
    End if

    if request.QueryString("id")<>"" then
    call GetRecord()
    End if


    Sub SaveRecord()

    dim rs
    dim cn

    set cn = server.CreateObject("Adodb.Connection")
    set rs = server.CreateObject("Adodb.Recordset")

    cn.Open conn

    if Uploader.Files.count <> 0 then
    File = Uploader.Files.Items()
    File(0).SavetoDisk Server.MapPath("../images/products")
    filename = File(0).Filename
    else
    filename = ""
    End if

    if Uploader.Form("id")="" then
    rs.open "Select * From Products",cn,2,3
    rs.addnew
    rs.fields("productname") = productname
    if filename <>"" then rs.fields("image") = filename
    rs.fields("details") = details
    rs.fields("categoryid") = category
    rs.update
    msg = "Prodotto salvato"
    saved = true
    else
    rs.open "Select * From Products Where ProductID=" & Uploader.Form("id"),cn,2,3
    rs.fields("productname") = productname
    'rs.fields(TRIM("quantita_minima")) = quantita_minima
    rs.fields("details") = details
    rs.fields("categoryid") = category
    if filename <>"" then rs.fields("image") = filename
    rs.update
    msg = "Il regord è stato aggiornato"
    saved = true
    End if

    rs.close
    cn.close
    set rs = nothing
    set cn = nothing

    End Sub


    Sub GetRecord()

    dim rs
    dim cn
    set cn = server.CreateObject("Adodb.Connection")
    set rs = server.CreateObject("Adodb.Recordset")

    cn.Open conn
    rs.open "Select * From Products Where ProductID=" & request.QueryString("id"),cn
    if not rs.eof then
    productname = rs.fields("productname")
    details = rs.fields("details")
    category = rs.fields("categoryid")
    filename = rs.fields("image")

    End If
    rs.close
    cn.close
    set rs = nothing
    set cn = nothing
    msg = "Product Record is loaded."
    End Sub
    %>

    <html>
    <head>
    <title>Admin</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="style.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    .Stile1 {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
    }
    .Stile2 {font-size: 12px}
    .Stile3 {
    color: #FFFFFF;
    font-weight: bold;
    }
    -->
    </style>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>

    <body>
    <p align="center" class="Stile1">Amministrare Prodotti e Categorie </p>
    <p align="center"> <font color="#FF0000"><%= msg%></font></p>
    <form action="" method="post" enctype="multipart/form-data" name="form1">
    <table width="806" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="50%"><table width="500" height="239" border="0" align="center" cellpadding="0" cellspacing="5" bordercolor="#666666" bgcolor="#E0DFE3">
    <tr bgcolor="#FF6600">
    <td height="23" colspan="2" bgcolor="#97C24E"><span class="Stile3"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Aggiungi
    un nuovo prodotto </font></span></td>
    </tr>
    <tr>
    <td height="23"></td>
    <td></td>
    </tr>
    <tr>
    <td width="37%" height="23"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nome
    Prodotto </font></td>
    <td width="63%"><input name="name" type="text" id="name" value="<%=productname%>"></td>
    </tr>
    <tr>
    <td height="26"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Categoria</font></td>
    <td><select name="category" id="select4">
    <%
    dim rs1
    dim cn1
    set cn1 = server.CreateObject("Adodb.Connection")
    set rs1 = server.CreateObject("Adodb.Recordset")
    cn1.Open conn
    rs1.open "Select * From ProductCategories",cn1
    %>
    <option value="0" selected >Select</option>
    <option value="0" >-</option>
    <%if not rs1.eof then
    while not rs1.eof%>
    <option value="<%=rs1.fields("CategoryID")%>" <%if CLng(Category)=rs1.fields("CategoryID") then response.Write("Selected")%>><%=rs1.fields("Catego ryName")%></option>
    <%
    rs1.movenext
    wend
    end if
    %>
    </select> </td>
    </tr>
    <tr>
    <td height="9" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Foto Miniatura </font></td>
    <td><input type="file" name="file">
    <font face="Arial, Helvetica, sans-serif" color="#FF0000"><%= filename%></font></td></tr>
    <tr>
    <td height="10" valign="top"></td>
    <td></td>
    </tr>
    <tr>
    <td height="9" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Descrizione breve </font></td>
    <td><textarea name="details" cols="40" rows="3" id="textarea2"><%=shortdetails%></textarea> </td>
    </tr>
    <tr>
    <td height="9" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Descrizione lunga </font></td>
    <td><textarea name="details" cols="40" rows="5" id="textarea2"><%=details%></textarea> </td>
    </tr>
    <tr>
    <td height="26"></td>
    <td></td>
    </tr>
    <tr>
    <td height="26"></td>
    <td><input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset"> </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <input name="id" type="hidden" id="id" value="<%=request.querystring("id")%>">
    </form>


    </p>
    <p class="Stile1"><span class="Stile2">Visualizza </span></p>
    <p class="Stile2"></p>
    <p class="Stile1"><span class="Stile2">Torna al Main</span></p>
    </body>
    </html>

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Devi cambiare script di upload questo non lo consente.
    Di gratuito c'è questo: http://www.creamweb.it/script/mostra.../?id_script=12

    Roby

  3. #3
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177
    Grazie Roby, quindi devo anche rivedere il form?

    temo che non ne uscirò vivo

    Ci provo subito grazie mille

  4. #4
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177
    mi stanno sudando le unghie, come si fa a riadattare sta roba VVoVe:

  5. #5
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Nel forum ci sono milioni di esempi con quel codice.

    Roby

  6. #6
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177
    Scusa l'ignoranza ma ho bisogno di una dritta a che fa riferimento la .SetPath????
    :master:

  7. #7
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Guarda tutti gli esempi dello zip.

    Roby

  8. #8
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177
    bho ci rinuncio è troppo difficile per le mie capacità, non sono in grado di cavarmela da solo, grazie comunque.

    Ciao



    PS: se a qualcuno viene in mente una soluzione lo ringrazio in anticipo

  9. #9
    Originariamente inviato da vispone
    bho ci rinuncio è troppo difficile per le mie capacità, non sono in grado di cavarmela da solo, grazie comunque.

    Ciao



    PS: se a qualcuno viene in mente una soluzione lo ringrazio in anticipo
    Prova a guardare questo 3D , si parla esattamente di quello che vuoi fare tu usando l'Upload di Baol.

  10. #10
    Utente di HTML.it L'avatar di vispone
    Registrato dal
    Feb 2003
    Messaggi
    177
    Grazie per la dritta Michele ci ho provato subito e mi da questo errore:

    Oggetto Request, ASP 0207 (0x80004005)
    Impossibile utilizzare l'insieme Request.Form dopo aver richiamato il metodo BinaryRead.
    /medicalupload/Upload_database.asp, line 20

    ho fatto una ricerca e tra le varie discussioni ho letto di componenti da installare mi fa strano.... mi fa molto strano

    risulta anche a te e se è si quale componente

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.