Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    16

    upload eliminare file nel database

    CIAO A TUTTI!!!!
    allora mi spiego, ho a chefare un un codice asp per uplodare file in un database con il metodo binario.
    l'upload funziona correttamente, anche la visualizzazione dei file contenuti nel db e la corretta visualizzazione delle immagini, la mia domanda è: c'è un codice che mi permette di cancellare i file all'interno del database?
    esiste un DELETE nel codice?


    il procedimento del mio upload è preso dal seguente ...

    indirizzo

    ciao a tutti e grazie....

  2. #2
    Utente di HTML.it L'avatar di Gioba66
    Registrato dal
    Jun 2002
    Messaggi
    2,189
    hai provato ad eseguire una query di update

    UPDATE tabella set nomecampoimmagine = null

    comunque mi sa che per recuperare spazio davvero devi fare la compattazione

    PS: pessima idea mettere le img nel db, specie se il db è access
    Tutti vogliono parlare, nessuno sa ascoltare.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    16
    hai provato ad eseguire una query di update

    UPDATE tabella set nomecampoimmagine = null

    comunque mi sa che per recuperare spazio davvero devi fare la compattazione

    PS: pessima idea mettere le img nel db, specie se il db è access


    ciao...
    il data base è access...immaginavo che il problema era lui!
    come faccio allora a mettere le immagini fuoridal db?

    grazie...

  4. #4
    Utente di HTML.it L'avatar di Gioba66
    Registrato dal
    Jun 2002
    Messaggi
    2,189
    salvi le immagini nel file sysstem
    metti nel db solo il path ed il nome immagine
    Tutti vogliono parlare, nessuno sa ascoltare.

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    16
    mi potresti indicare dove,che non ho capito.
    ti posto il codice ciao e grazie...


    <%@LANGUAGE="VBSCRIPT"%>

    <% ' Insert.asp %>

    <%
    Response.Buffer = True

    ' load object
    Dim load
    Set load = new Loader

    ' calling initialize method
    load.initialize

    ' File binary data
    Dim fileData
    fileData = load.getFileData("file")
    ' File name
    Dim fileName
    fileName = LCase(load.getFileName("file"))
    ' File path
    Dim filePath
    filePath = load.getFilePath("file")
    ' File path complete
    Dim filePathComplete
    filePathComplete = load.getFilePathComplete("file")
    ' File size
    Dim fileSize
    fileSize = load.getFileSize("file")
    ' File size translated
    Dim fileSizeTranslated
    fileSizeTranslated = load.getFileSizeTranslated("file")
    ' Content Type
    Dim contentType
    contentType = load.getContentType("file")
    ' No. of Form elements
    Dim countElements
    countElements = load.Count
    ' Value of text input field "fname"
    Dim fnameInput
    fnameInput = load.getValue("fname")
    ' Value of text input field "lname"
    Dim lnameInput
    lnameInput = load.getValue("lname")
    ' Value of text input field "profession"
    Dim profession
    profession = load.getValue("profession")

    ' destroying load object
    Set load = Nothing
    %>

    <html>
    <head>
    <title>Inserts Images into Database</title>
    <style>
    body, input, td { font-family:verdana,arial; font-size:10pt; }
    </style>
    </head>
    <body>
    <p align="center">
    Inserting Binary Data into Database

    To see inserted data click here
    </p>

    <table width="700" border="1" align="center">
    <tr>
    <td>File Name</td><td><%= fileName %></td>
    </tr><tr>
    <td>File Path</td><td><%= filePath %></td>
    </tr><tr>
    <td>File Path Complete</td><td><%= filePathComplete %></td>
    </tr><tr>
    <td>File Size</td><td><%= fileSize %></td>
    </tr><tr>
    <td>File Size Translated</td><td><%= fileSizeTranslated %></td>
    </tr><tr>
    <td>Content Type</td><td><%= contentType %></td>
    </tr><tr>
    <td>No. of Form Elements</td><td><%= countElements %></td>
    </tr><tr>
    <td>First Name</td><td><%= fnameInput %></td>
    </tr><tr>
    <td>Last Name</td><td><%= lnameInput %></td>
    </tr>
    <tr>
    <td>Profession</td><td><%= profession %></td>
    </tr>
    </table>



    <p style="padding-left:220;">
    <%= fileName %> data received ...

    <%
    ' Checking to make sure if file was uploaded
    If fileSize > 0 Then

    ' Connection string
    Dim connStr
    connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
    connStr = connStr & Server.MapPath("mdb-database/FileDB.mdb")

    ' Recordset object
    Dim rs
    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.Open "Files", connStr, 2, 2

    ' Adding data
    rs.AddNew
    rs("File Name") = fileName
    rs("File Size") = fileSize
    rs("File Data").AppendChunk fileData
    rs("Content Type") = contentType
    rs("First Name") = fnameInput
    rs("Last Name") = lnameInput
    rs("Profession") = profession
    rs.Update

    rs.Close
    Set rs = Nothing

    Response.Write "<font color=""green"">File was successfully uploaded..."
    Response.Write "</font>"
    Else
    Response.Write "<font color=""brown"">No file was selected for uploading"
    Response.Write "...</font>"
    End If


    If Err.number <> 0 Then
    Response.Write "
    <font color=""red"">Something went wrong..."
    Response.Write "</font>"
    End If
    %>
    </p>



    <table border="0" align="center">
    <tr>
    <form method="POST" enctype="multipart/form-data" action="Insert.asp">
    <td>First Name :</td><td>
    <input type="text" name="fname" size="40" ></td>
    </tr>
    <td>Last Name :</td><td>
    <input type="text" name="lname" size="40" ></td>
    </tr>
    <td>Profession :</td><td>
    <input type="text" name="profession" size="40" ></td>
    </tr>
    <td>File :</td><td>
    <input type="file" name="file" size="40"></td>
    </tr>
    <td> </td><td>
    <input type="submit" value="Submit"></td>
    </tr>
    </form>
    </tr>
    </table>

    </body>
    </html>

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.