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

    comando delete.....mi servirebbe piccolissimo aiuto

    buongirono a tutti ed auguri


    <% Dim fso
    Set fso = Server.CreateObject("Scripting.FileSystemObject") fso.DeleteFile(Server.MapPath("name.jpg"))
    Set fso = Nothing %>
    ho questo script per eliminare un determinato file dal server....
    adesso dopo aver creato un apposito form


    <html>
    <head>
    <title>nuovo</title>
    <body>



    <form name="form1" method="post" action="delete.asp"></P>

    <tr>
    <td bgcolor="#C0C0C0" width="84"><span class="style11"><font size="2">
    Inserisci il nominativo</font></span></td>
    <td bgcolor="#C0C0C0" width="152">
    <input name="filename" type="text" id="filename" size="56"></td>
    </tr>
    <tr>
    <td width="84"></td>
    <td width="152"><input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset"></td>
    </tr>
    </table>
    </html>

    vorrei che digitando il nome del file nella casella del testo "filename" questo venga riconosciuto ed eliminato qualcuno sa come fare......?????????

    P.S. certo sarei molto piu' felice se capissi come inserire un tasto ELIMINA nel seguente
    script....



    <%
    '************************************************* ******
    '************************************************* ******
    %>

    <%
    ' This function takes a filename and returns the appropriate image for
    ' that file type based on it's extension. If you pass it "dir", it assumes
    ' that the corresponding item is a directory and shows the folder icon.
    Function ShowImageForType(strName)
    Dim strTemp

    ' Set our working string to the one passed in
    strTemp = strName

    ' If it's not a directory, get the extension and set it to strTemp
    ' If it is a directory, then we already have the correct value
    If strTemp <> "dir" Then
    strTemp = LCase(Right(strTemp, Len(strTemp) - InStrRev(strTemp, ".", -1, 1)))
    End If

    ' Debugging line used to perfect that above string parser
    'Response.Write strTemp

    ' Set the part of the image file name that's unique to the type of file
    ' to it's correct value and set this to strTemp. (yet another use of it!)
    Select Case strTemp
    Case "asp"
    strTemp = "asp"
    Case "dir"
    strTemp = "dir"
    Case "htm", "html"
    strTemp = "htm"
    Case "gif", "jpg"
    strTemp = "img"
    Case "txt"
    strTemp = "txt"
    Case Else
    strTemp = "misc"
    End Select

    ' All our logic is done... build the IMG Tag for display to the browser
    ' Place it into... where else... strTemp!

    ' My images are all GIFs and all start with "dir_" for my own sanity.
    ' They end with one of the values set in the select statement above.

    strTemp = "[img][/img]"

    ' Set return value and exit function
    ShowImageForType = strTemp
    End Function
    'That's it for functions on this one!
    %>


    <%' Now to the Runtime code:
    Dim strPath 'Path of directory to show
    Dim objFSO 'FileSystemObject variable
    Dim objFolder 'Folder variable
    Dim objItem 'Variable used to loop through the contents of the folder

    ' You could just as easily read this from some sort of input, but I don't
    ' need you guys and gals roaming around our server so I've hard coded it to
    ' a directory I set up to illustrate the sample.
    ' NOTE: As currently implemented, this needs to end with the /
    strPath = "./miacartella/"

    ' Create our FSO
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

    ' Get a handle on our folder
    Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))

    ' Show a little description line and the title row of our table
    %>
    <p align="center">Contents of <%= strPath %>

    <script type="text/javascript" src="mootools.js"></script>
    <script type="text/javascript" src="moopop.js"></script>



    </p>
    <div align="center">
    <center>

    <TABLE BORDER="5" BORDERCOLOR="green" CELLSPACING="0" CELLPADDING="2" style="border-collapse: collapse">
    <TR BGCOLOR="#006600">
    <TD align="left"><FONT COLOR="#FFFFFF">File Name:</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">File Size (bytes):</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">Date Created:</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">File Type:</FONT></TD>

    </TR>
    <%

    ' First I deal with any subdirectories. I just display them and when you
    ' click you go to them via plain HTTP. You might want to loop them back
    ' through this file once you've set it up to take a path as input. It seems
    ' like the logical thing to do to me at least!
    For Each objItem In objFolder.SubFolders
    ' Deal with the stupid VTI's that keep giving our visitors 404's
    If InStr(1, objItem, "_vti", 1) = 0 Then
    %>

    <TR BGCOLOR="#CCFFCC">
    <TD ALIGN="left" ><%= ShowImageForType("dir") %><%= objItem.Name %></TD>
    <TD ALIGN="left"><%= objItem.Size %></TD>
    <TD ALIGN="left" ><%= objItem.DateCreated %></TD>
    <TD ALIGN="left" ><%= objItem.Type %></TD>

    </TR>
    <%
    End If
    Next 'objItem

    ' Now that I've done the SubFolders, do the files!
    For Each objItem In objFolder.Files
    %>
    <TR BGCOLOR="#CCFFCC">
    <TD ALIGN="left" ><%= ShowImageForType(objItem.Name) %><%= objItem.Name %></TD>
    <TD ALIGN="left"><%= objItem.Size %></TD>
    <TD ALIGN="left" ><%= objItem.DateCreated %></TD>
    <TD ALIGN="left" ><%= objItem.Type %></TD>

    </TR>
    <%
    Next 'objItem

    ' All done! Kill off our object variables.
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing

    ' Oops... I almost forgot to close up the table. IE will forgive you,
    ' but Netscape will catch you on this error - AS IT SHOULD!

    ' Ok, so I'm a little odd being a Microsoft supporter and yet I still
    ' use Netscapes's browser... I just like it better... so sue me!
    '
    ' I probably shouldn't say that too loudly...
    ' ...you never know what the next lawsuit will be!
    %>
    </TABLE></center>
    </div>
    <p align="left"></p>
    un grazie formtao famiglia a chiunque riesca ad aiutarmi ( o x lo meno ci provi )

    e di nuovo auguri a tutti

  2. #2
    codice:
    <TABLE BORDER="5" BORDERCOLOR="green" CELLSPACING="0" CELLPADDING="2" style="border-collapse: collapse">
    <TR BGCOLOR="#006600">
    <TD align="left"><FONT COLOR="#FFFFFF">File Name:</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">File Size (bytes):</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">Date Created:</FONT></TD>
    <TD align="left"><FONT COLOR="#FFFFFF">File Type:</FONT></TD>
    <td>Elimina file</td>
    
    </TR>
    <%
    
    ' First I deal with any subdirectories. I just display them and when you
    ' click you go to them via plain HTTP. You might want to loop them back
    ' through this file once you've set it up to take a path as input. It seems
    ' like the logical thing to do to me at least!
    For Each objItem In objFolder.SubFolders
    ' Deal with the stupid VTI's that keep giving our visitors 404's
    If InStr(1, objItem, "_vti", 1) = 0 Then
    %>
    
    <TR BGCOLOR="#CCFFCC">
    <TD ALIGN="left" ><%= ShowImageForType("dir") %> <%= objItem.Name %></TD>
    <TD ALIGN="left"><%= objItem.Size %> </TD>
    <TD ALIGN="left" ><%= objItem.DateCreated %> </TD>
    <TD ALIGN="left" ><%= objItem.Type %> </TD>
    <td>Elimina>
    
    </TR>
    delete.asp
    codice:
    <% Dim fso 
    Set fso = Server.CreateObject("Scripting.FileSystemObject") 
    fileDaCancellare=Request.Querystring("percorso")&Request.Querystring("nome")
    Response.write(fileDaCancellare)&"
    "
    fso.DeleteFile(fileDaCancellare) 
    Set fso = Nothing 
    %>
    File cancellato correttamente!
    Eventualmente fai un redirect alla pagina di provenienza

  3. #3
    ho aggiunto le righe nel file dir_list ( come da tua specifica)
    ho RICREATO IL FILE DELETE.ASP (copiando le tue righa)
    ma il risultato è :
    ./franx/index.html
    Microsoft VBScript runtime error '800a0035'
    File not found
    /test/sito_osl/pagine_personali/Admin/Admin/delete.asp, line 5

  4. #4
    qual'è il percorso completo del file che hai provato a cancellare?

  5. #5
    /test/sito_osl/pagine_personali/Admin/Admin/franx/nomefile

  6. #6
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    A) Su che server sei? (es:aruba)
    B) Le cartelle hanno diritti di scrittura/lettura?
    C) Sempre meglio verificare che il file (proprio x non avere errori) esista.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  7. #7
    A) = aruba
    B) = si e' una cartella creata dentro la public ( ed in piu' la uso gia' per caricare i files di upload)
    C) = il file esiste e' presente nella cartella


    se invece creo un link a questo file.... tutto va ok

    <%
    Dim objFSO
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

    'Il file viene cancellato
    objFSO.DeleteFile("c:\freeasp.txt")

    Set objFSO = Nothing
    %>

  8. #8
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Metti la pagina online, per provare a fare qualche test.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  9. #9
    la pagina e' online
    riesco a fare l'upload senza problemi
    riesco a cencellare un file se nel delete.asp imposto a priori il nome del file
    non funsiona solo se uso il tasto elimina come se nn riconoscesse il nome del file

    è coem se non lo caricasse corretto nella pagina delete.asp

  10. #10
    Originariamente inviato da Luis_Cypher
    /test/sito_osl/pagine_personali/Admin/Admin/franx/nomefile
    ricordati che poi questo indirizzo "logico" lo devi far diventare "fisico" con Server.MapPath


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.