|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting Files From Server
Hi all,
How can I call all files in a folder on a server and then give a user the option to delete them? -Thanks in advance |
|
#2
|
|||
|
|||
|
Trivial...
First, you read on FSO(File System Object) Then when you're ready, you start coding! Seriously...your question is too large, are you expecting me, or anyone for that matter to give you the entire code??? Anyway... 1) Create the object like this: Set objFSO = CreateObject("Scripting.FileSystemObject") 2) Then read the folder you want and display it inside a nicely formatted html <table>...</table> 3) Add a delete <button> in each <tr>...</tr> of your <table>...</table> 4) Add an onclick attribute to that button calling a javascript function which is created inside the <head>...</head> portion of your code. 5) The function should submit the page to another page where you then declare another objFSO object 6) As the function submits to the other page, it passes a parameter, the actual file name the user wanted to delete. 7) You then delete the file in question using FSO You must read on FSO in order to understand this... Hope this helps! Sincerely Vlince |
|
#3
|
|||
|
|||
|
Quote:
Nope I never ask for code Your explanation helped, I know it's not easy Thanks |
|
#4
|
|||
|
|||
|
Yes... I shouldn't assume that you wanted code you are right!
what can I say...people usually ask for code without trying first My bad Digitalosophy Hope the information I gave you will help you in your quest! Sincerely Vlince |
|
#5
|
|||
|
|||
|
Well boy you weren't kidding when you said "Trivial". I am reading about the File Sytem Object right now. Wow very powerful but also very complicated. Let me ask you this:
Here is what I have to do: I create an admin console for our local intranet. it controls the whole site, including file upload and all that good stuff. Now the problem is this: The admin has option to delete entries in DB which point to pdf files. Now obviously when he deletes the record the file still remains on the server. Should I just give him access to that folder so he can delete old PDF files instead of getting into all this? [edit] oh and thanks i really appreciate your time and advise [/edit] |
|
#6
|
|||
|
|||
|
Well you first create your SQL query that DELETEs the entry in your database, then you execute the Query.
Then, still inside the *same* asp page, you create the objFSO object and delete the file name associated to the entry you've deleted. A good way is to get the file's path first! Then DELETE in the database! Then delete on the physical drive using the file's path you've retrieved! Hope this helps! Sincerely Vlince |
|
#7
|
|||
|
|||
|
hmm
Code:
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "C:\InetPub\wwwroot\iop\file.asp", False
Set objFSO = Nothing
I guess all I have to do now is make file.asp the actual file name, which shouldn't be hard because I already have a record set which calls it. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Deleting Files From Server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|