Click to See Complete Forum and Search --> : HTML Delete Script
dominicbelfiori
03-17-2010, 10:17 AM
Good morning, and happy St. Patty's day everyone. I'm almost done building my page (just finishing up the admin panel). and am having some troubles getting the delete option to work properly.
when you click delete, the file DOES delete, but it prompts error:
__________
Attribute validation error for tag cfoutput.
The value of the attribute query, which is currently dirQuery, is invalid.
The error occurred in C:\inetpub\wwwroot\test.com\admin\upload.cfm: line 51
49 : <table>
50 : <!---Start the looping query--->
51 : <cfoutput query="dirQuery">
52 : <CFIF name IS NOT "upload.cfm">
53 : <tr>
______
This is the current code i've put in so far.
______
<cfoutput query="dirQuery">
<CFIF name IS NOT "upload.cfm">
<tr>
<td><a href="#cgi.SCRIPT_NAME#?action=delete&fileName=#name#">[ Delete ]</a></td>
<td><A href="http://www.test.com/#name#">[ View/Download ]</a></td>
<td>#name#</td>
</tr>
</CFIF>
</cfoutput>
Any ideas?
thefysaint
03-18-2010, 12:51 PM
Would it be possible to see more of your code? Did you define a cfquery tag before the cfoutput tag? The cfquery tag defines the name for the query.
So in this case, you should have something like this:
<cfquery name="dirQuery" datasource="whatever">
...your SQL query
</cfquery>
<cfoutput query="dirQuery">
<CFIF name IS NOT "upload.cfm">
<tr>
<td><a href="#cgi.SCRIPT_NAME#?action=delete&fileName=#name#">[ Delete ]</a></td>
<td><A href="http://www.test.com/#name#">[ View/Download ]</a></td>
<td>#name#</td>
</tr>
</CFIF>
</cfoutput>
dominicbelfiori
03-18-2010, 02:00 PM
sure thing thefysaint, this is the whole code for the page:
_________________________________
<CFSET SendFileTo = "C:/inetpub/wwwroot/test.com/">
<CFPARAM NAME="Action" DEFAULT="">
<title>test Admin Panel | Upload</title>
<html>
<body>
<CFIF Action IS "">
<!---Get all the files in the current directory--->
<cfdirectory directory="#SendFileTo#" name="dirQuery" action="LIST" FILTER="*.pdf" sort="Name, Type">
<!---Show all the files--->
<table> <tr>
<td colspan="2" align="center"><img src="../Images/logo.jpg" alt="prism Admin" width="333" height="120" /></td>
</tr></table>Files must be in .pdf format
</CFIF>
<!---If the File Upload Form has been filled out, then execute the code to upload the actual file specified--->
<CFIF isDefined("form.FileContents")>
<cffile action = "upload"
fileField = "FileContents"
destination = "#SendFileTo#"
nameconflict="makeunique">
<P style="color: red;">File has been successfully uploaded.<br />
click the below link to view new content. </P>
<a href="upload.cfm"><b>[Click here to update list.] </a></b>
</CFIF>
<!---If the "Delete" link has been clicked, then remove the file that was passed in the URL string--->
<CFIF Action IS "Delete">
<cffile action = "delete"
file = "#SendFileTo##FileName#">
<P style="color: red;"><b>File has been successfully removed on the server.</P><b/>
<a style="color: black" href="upload.cfm"> <b><h1>[ Click here to go back ].</a></b></h1>
</CFIF>
<!---Show the upload form--->
<br /><form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
name="uploadForm" enctype="multipart/form-data">
<br /> <input name="FileContents" type="file">
<br />
<br /> <input name="submit" type="submit" value="Upload File">
</form>
<!---Get all the files in the current directory--->
<table>
<!---Start the looping query--->
<cfoutput query="dirQuery">
<CFIF name IS NOT "upload.cfm">
<tr>
<td><a href="#cgi.SCRIPT_NAME#?action=delete&fileName=#name#">[ Delete ]</a></td>
<td><A href="http://www.test/#name#">[ View/Download ]</a></td>
<td>#name#</td>
</tr>
</CFIF>
</cfoutput>
</table>
<br /><br />
<a href="members_only.cfm">Click here to go back.</a>
</body>
</html>
thefysaint
03-19-2010, 04:36 PM
I guess the problem is that the name 'dirQuery' is only defined if the actio is ""
<CFIF Action IS "">
<!---Get all the files in the current directory--->
<cfdirectory directory="#SendFileTo#" name="dirQuery" action="LIST" FILTER="*.pdf" sort="Name, Type">
<!---Show all the files--->
<table> <tr>
<td colspan="2" align="center"><img src="../Images/logo.jpg" alt="prism Admin" width="333" height="120" /></td>
</tr></table>Files must be in .pdf format
</CFIF>
So chances are the program does not know this name when the action is "DELETE"...
dominicbelfiori
03-19-2010, 04:45 PM
Yup :) i actually just got it working, Thanks thefysaint!. I re-did some of it. This is the ending code (in case someone else runs into this error):
<CFSET Database = "testdatabase">
<CFPARAM NAME="Action" DEFAULT="">
<CFSET SendFileTo = "C:/inetpub/wwwroot/test.com/">
<html>
<head>
<title>test Admin Panel</title>
</head>
<h1>PRISM Upload Panel</h1>
<P style="color: red;">Files must be in .pdf format.</P>
<!---If the File Upload Form has been filled out, then execute the code to upload the actual file specified--->
<CFIF isDefined("form.FileContents")>
<cffile action = "upload"
fileField = "FileContents"
destination = "#SendFileTo#"
nameconflict="makeunique">
<P style="color: red;">File has been successfully uploaded.</P>
</CFIF>
<!---If the "Delete" link has been clicked, then remove the file that was passed in the URL string--->
<CFIF Action IS "Delete">
<cffile action = "delete"
file = "#SendFileTo##FileName#">
<P style="color: red;">File has been successfully removed on the server.</P>
</CFIF>
<!---Show the upload form--->
<form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
name="uploadForm" enctype="multipart/form-data">
<input name="FileContents" type="file">
<br>
<input name="submit" type="submit" value="Upload File">
</form>
<!---Get all the files in the current directory--->
<cfdirectory directory="#SendFileTo#" name="dirQuery" action="LIST" FILTER="*.pdf">
<table>
<!---Start the looping query--->
<cfoutput query="dirQuery">
<CFIF name IS NOT "upload.cfm">
<tr>
<td><a href="#cgi.SCRIPT_NAME#?action=delete&fileName=#name#">[ Delete ]</a></td>
<td><a href="http://www.test/#name#" target="_blank">[ View ]</a></td>
<td>#name#</td>
</tr>
</CFIF>
</cfoutput>
</table>
<br />
<br />
<a href="members_only.cfm">Click here to go back.</a>
thefysaint
03-20-2010, 08:36 PM
np ;-)
good luck with the rest