Hi
I have a site that displays images along with details of the images from a database.
I'd like to be able to select a number of these images and delete the details of the image from the database as well as the actual images from the server.
So far i've managed to delete the records from the database using a delete command but the script i have used to delete the image itself does not seem to be working.
The script does not throw an error but the page simply does not load.
The code is below.
Thanks in advance.
Regards
Elliot
---------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/con_imglib.asp" -->
'delete records from db
<%
if Request.QueryString("delete") <> "" then
if(Request.QueryString("delete") <> "") then cmd_delete__var_imageref = Request.QueryString("delete")
%>
<%
set cmd_delete = Server.CreateObject("ADODB.Command")
cmd_delete.ActiveConnection = MM_con_imglib_STRING
cmd_delete.CommandText = "DELETE FROM tbl_images WHERE image_ref IN ('" + Replace(cmd_delete__var_imageref, "'", "''") + "')"
cmd_delete.CommandType = 1
cmd_delete.CommandTimeout = 0
cmd_delete.Prepared = true
cmd_delete.Execute()
End If
%>
'delete file
<%Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "C:\InetPub\ Image Library\images\library\thumbs\"&Request.QueryString("delete")&".jpg", False
Set objFSO = Nothing%>
'redirect back to the gallery page
<%
Response.Redirect("admin_gallery.asp?cat="&Request.QueryString("cat"))
%>
I have a site that displays images along with details of the images from a database.
I'd like to be able to select a number of these images and delete the details of the image from the database as well as the actual images from the server.
So far i've managed to delete the records from the database using a delete command but the script i have used to delete the image itself does not seem to be working.
The script does not throw an error but the page simply does not load.
The code is below.
Thanks in advance.
Regards
Elliot
---------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/con_imglib.asp" -->
'delete records from db
<%
if Request.QueryString("delete") <> "" then
if(Request.QueryString("delete") <> "") then cmd_delete__var_imageref = Request.QueryString("delete")
%>
<%
set cmd_delete = Server.CreateObject("ADODB.Command")
cmd_delete.ActiveConnection = MM_con_imglib_STRING
cmd_delete.CommandText = "DELETE FROM tbl_images WHERE image_ref IN ('" + Replace(cmd_delete__var_imageref, "'", "''") + "')"
cmd_delete.CommandType = 1
cmd_delete.CommandTimeout = 0
cmd_delete.Prepared = true
cmd_delete.Execute()
End If
%>
'delete file
<%Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "C:\InetPub\ Image Library\images\library\thumbs\"&Request.QueryString("delete")&".jpg", False
Set objFSO = Nothing%>
'redirect back to the gallery page
<%
Response.Redirect("admin_gallery.asp?cat="&Request.QueryString("cat"))
%>