Delete Multiple Records and Associated Files
Delete Multiple Records and Associated Files. This is ideally a comlementary job to ASP upload. Once you have uploaded files to a directory and kept track of them in a database, you may want to do a cleanup once in a while. This is what this extension does.
MSG for Waldo: a couple of weeks ago you did a terrific job in helping me solve the refresh problem with the DB Fields menu, when applied twice. Now I have this extension working but, much as I have tried, I still can't get rid of the red ! mark. I have rewritten all my search patterns and am positive that they work. I am inclined to believe that the cause should be found either in the js functions that I modified to solve the refresh problem or in the cname parameter. Maybe it needs to be searched differently if it is also used in a different (shared) xml file?
At all events, now the red ! has no effect whatever in the functioning of the extension: it doesn't change anything and it simply stays there, horrible and confusing! Could you please help me once again?
This ASP-only extension is designed to help in creating a page for deleting multiple records, as well as the files these records refer to. This is typically the case with files that have been uploaded from a webpage. These files are generally referred to in a database table. So this extension expects a string parameter, submitted by a form on a separate page, as well as a database table with at least a unique ID field and a field containing the file name. You may also need to specify additional subfolder information, based on the physical location of the files on the server, while the absolute path is automatically retrieved here with the File.Mappath method. You should also make sure that you have write privileges for deleting the files on the server folder. For further reference, please use the help function in this server behaviour's window.
Comments
I am sorry
Multiple Delete When Image Field Empty
Excellent extension, however, if I have a database full of details where some people have and some people haven't uploaded images, the delete functions seems to stop whenever it comes across an empty image field.
If I try to run it on a table where an image field is always present it works just fine.
I know this is only a Beta version, but have you any ideas how I can work around this other than re-running the delete until all the records have gone? Thanks.
RE: Multiple Delete When Image Field Empty
I haven't tested this, but it should do the job.
replace the code in the corresponding block with:
<%
Do While rsDel.EOF=False
dim TempPath
TempPath=(Server.Mappath(("YourSubfolder") &"/" & rsDel("Your DB__Field__with__File__Info")))
rsDel.Delete
if File.FileExists(TempPath)=1 then
File.DeleteFile(TempPath)
End if
rsDel.MoveNext
Loop
rsDel.Close
Set file="Nothing"
Set rsdel="Nothing"
else Response.redirect("Redirect__page_if__no__selection__made")
end if
Response.Redirect "Redirect__page_after__delete__action"
%>
Let me know if this helps and best regards,
Piero Mattirolo
RE: RE: Multiple Delete When Image Field Empty
Piero,
Thanks, this does now delete all the records in the table, but as soon as it comes across an empty image field it stops deleting the rest of the associated files.
You must me logged in to write a comment.