Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630

    cancellare tutti i selezionati

    Carissimi,
    tramite questo script mi elenco tutte le immagini presenti in una cartella su server
    codice:
    <table border="1" width="553" id="table1" bordercolor="#FFFFFF" bordercolorlight="#C0C0C0">
        
    </font>[/b]
    		<tr>
    			<td align="center" width="95">
    			<p align="center">
    			<font face="Tahoma" size="2">Foto</font></td>
    			<td align="center" width="212">
    			<font face="Tahoma" size="2">Nome 
    			file</font></td>
    			<td align="center" width="140">
    			<font face="Tahoma" size="2">Caricata il</font></td>
    			<td align="center">
    			<p align="center"><font face="Tahoma" size="2">
    			Cancella file</font></td>
    </tr>
    
    <%
    Dim objFso, objFolder, objFiles
    Dim strFolder, strFile, strPath, strExt
    
    strPath = "fotogallery/" 
    strExt = ".JPG"
    
    Set objFso = Server.createObject("Scripting.FileSystemObject") 
    Set objFolder = objFso.GetFolder(Server.MapPath(strPath)) 
    Set objFiles = objFolder.Files 
    
    set custRs = Server.CreateObject("ADODB.Recordset")
    custRs.Fields.Append "nome", 200, 300 ' adVarChar
    custRs.Fields.Append "data", 7 ' Date
    custRs.Open
    
    For Each strFile in objFiles
    
    custRs.AddNew
    custRs("nome") = strFile.name
    custRs("data") = strFile.DateCreated
    
    next
    
    custRs.Sort = "data DESC"
    
    custRs.movefirst
     
    Do until custRs.eof
     
    	if Right(lcase(custRs("nome")), Len(strExt)) = lcase(strExt) then 
    
        %>
    		<tr>
    			<td bgcolor="#FFFFFF" align="center">
    			<p align="center">
    			" rel="lightbox">[img]../../../square.aspx?img=fotogallery/<%=custRs([/img]&opx=84" ></p></td>
    			<td bgcolor="#FFFFFF"><font size="2" face="Verdana"><%=custRs("nome")%></font></td>
    			<td bgcolor="#FFFFFF" width="140" align="center"><font size="1" face="Verdana"><%=custRs("data")%></font></td>
    			<td bgcolor="#FFFFFF" width="77"><p align="center"><input type="checkbox" name="C1" value="ON"></td>
    	
    	<%  
    end if
    
       custRs.movenext
    loop
    
    Set objFso = Nothing 
    Set objFolder = Nothing
    Set objFiles = Nothing 
    custRs.Close
    set custRs = Nothing
    
    
    %>	
      </tr>
    	</table>
    potete aiutarmi ad implementare la possibilità di selezionarli tutti mediante checkbox(che ho già messo ma non saprei come impostarlo) per eliminare + file per volta?
    Grazie
    G.

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    questo lo script per cancellare per un file per volta
    codice:
    <%
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    sSourceFile = "d:\inetpub\webs\nomesitoit\public\fotogallery\"& request.form("file") &""
    
    ' Check if file exists to prevent error
    If oFSO.FileExists(sSourceFile) Then
    oFSO.DeleteFile sSourceFile
    End If
    
    response.redirect("elenco.asp")
    %>
    Grazie
    G.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    nessuno può aiutarmi?

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    nessun suggerimento?

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    Ho provato a fare questo ma non mi funziona....
    codice:
    Dim check
    
    check = split(request.form("file"),",")
    
    for each objFsoFile in check
    
    set objFso = Server.CreateObject("Scripting.FileSystemObject")
    Set objFsoFile = objFso.GetFile(Server.MapPath("/fotogallery/" & check))
    objFsoFile.Delete
    next
    
    Set objFsoFile = Nothing
    Set objFSO = Nothing 
    Set conn=Nothing
    Aiutatemi... grazie..
    G.

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    La request.form("file")) cosa ti riporta?

    Roby

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    mi riporta i checkbox selezionati dal form precedente, cioè i nomi dei file....
    cioè questo:

    codice:
    <input type="checkbox" name="file" value="<%=custRs("nome")%>">

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    check = split(request.form("file"),",")
    if IsArray(check) then
    set objFso = Server.CreateObject("Scripting.FileSystemObject")
    for xEl = 0 to Ubound(check)
    file = check(xEl)
    if objFso.FileExists (Server.MapPath("/fotogallery/" & file)) then
    objFsoFile.DeleteFile (Server.MapPath("/fotogallery/" & file))
    end if
    next
    Set objFSO = Nothing
    end if
    Roby

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    ho questo errore:

    Object required: 'objFsoFile'

  10. #10

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.