473,395 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to delete and download attachments?

769 512MB
Hey Everyone,

Well for the last few days i been trying to figure out how to delete attachments and download attachments to my computer. The deleting is sort of working and i don't know where to begin on downloading. Right now with the deleting it will delete from the attachments folder on the server but it does not delete from the database an was wondering if someone could explain what i am doing wrong on deleting attachments and how i could make it where a user could download an attachment to there computer? Here is what i have.

Expand|Select|Wrap|Line Numbers
  1. <cfparam name="form.confirmed" default="0">
  2.  
  3. <cfquery name="attachment" datasource="CustomerSupport">
  4.          SELECT fk_ticketID,description,path
  5.          FROM dbo.tbl_CS_attachments
  6.          WHERE fk_ticketID = #URL.pk_ticketID#
  7. </cfquery>
  8.  
  9.  
  10. <form method="post">
  11. <cfoutput query="ticket">
  12. <input type="hidden" name="pk_ticketID" id="pk_ticketID" value="#pk_ticketID#" />
  13. </cfoutput>
  14. <cfoutput query="attachment">
  15. <input type="hidden" name="fk_ticketID" id="fk_ticketID" value="#fk_ticketID#" />
  16. </cfoutput>
  17.  
  18. <cfoutput query="attachment">
  19. #description#
  20. <a href="attachments/#path#" target="_blank" >view</a>
  21. <br>
  22. <cfif form.confirmed EQ 1>
  23. <cflock timeout="60">
  24. <cffile action="delete" 
  25. file="C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\#path#">
  26. </cflock>
  27. </cfif>
  28. <input type="hidden" name="confirmed" value="1">
  29. <input type="hidden" name="fk_ticketID" value="#fk_ticketID#">
  30. <input type="submit" value="delete" onClick="return confirm('Are you sure you want to delete?')">
  31. </cfoutput>
  32. </form>
Thank you,
Rach
Oct 17 '08
107 11198
bonneylake
769 512MB
The cfparam is just there in case a path is not specified. You can set it to the empty string, then when outputting, if it's empty, you can just display a message instead of trying to download the file.

In download.cfm, have you changed the type attribute for the cfcontent tag? Note that you can force a download by setting the type to "application/unknown". That might be simplest solution in this case.

Hey Acoder,

Tried to set the type to what you said an well i am still getting the same error. Here is what it says.

No such file.

The file specified in CFContent does not exist: C:\Inetpub\Development\WWWRoot\RachelB\footprints\ form\attachments\encodeURIComponent(capt.108c1e44b 23c48a59fd6d459b143331f_386_3.jpg)

The error occurred while processing an element with a general identifier of (CFCONTENT), occupying document position (2:1) to (5:1) in the template file C:\Inetpub\Development\WWWRoot\RachelB\footprints\ form\download.cfm.


an this is what i have on the download page.

Expand|Select|Wrap|Line Numbers
  1. <cfheader name="Content-Disposition" value="attachment; filename=#path#">
  2. <cfcontent 
  3. file = "C:\Inetpub\Development\WWWRoot\RachelB\footprints\form\attachments\#path#" 
  4. type="application/unknown"
  5. >
Thank you,
Rach
Oct 27 '08 #101
acoder
16,027 Expert Mod 8TB
Obviously, it's not going to work (gah!). It should be:
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="download" value="Download" onClick="window.location.href='download.cfm?path='+encodeURIComponent(#path#);">
Note that the previous code was putting encodeURIComponent within the URL resulting in the "No such file" error.
Oct 27 '08 #102
bonneylake
769 512MB
Obviously, it's not going to work (gah!). It should be:
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="download" value="Download" onClick="window.location.href='download.cfm?path='+encodeURIComponent(#path#);">
Note that the previous code was putting encodeURIComponent within the URL resulting in the "No such file" error.
Hey Acoder,

i am getting a weird error. It says

Error: missing ) after argument list
Source Code:
window.location.href='download.cfm?path='+encodeUR IComponent(capt.2e780c0734e006b13d9c3f793cd88715_3 86_2.jpg);

it says its missing after capt. an here is what i have for the button
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="download" value="Download" 
  2. onClick="window.location.href='download.cfm?path='+encodeURIComponent(#path#);">
Thank you,
Rach
Oct 27 '08 #103
acoder
16,027 Expert Mod 8TB
Remove the spaces between UR and IC
Oct 27 '08 #104
bonneylake
769 512MB
Remove the spaces between UR and IC
Hey Acoder,

I don't know why but only when i put the code on here it shows the space between UR and IC even when i make sure it don't have a space between it before i submit.
but in my code its all together.

Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="download" value="Download" 
  2. onClick="window.location.href='download.cfm?path='+encodeURIComponent(#path#);
  3. ">

Thank you,
Rach
Oct 27 '08 #105
acoder
16,027 Expert Mod 8TB
I see what's happening now. #path# is being converted to a string without quotes which JavaScript doesn't recognise. Either set #path# to a JavaScript variable, or just put it in quotes:
Expand|Select|Wrap|Line Numbers
  1. encodeURIComponent('#path#')
Oct 27 '08 #106
bonneylake
769 512MB
I see what's happening now. #path# is being converted to a string without quotes which JavaScript doesn't recognise. Either set #path# to a JavaScript variable, or just put it in quotes:
Expand|Select|Wrap|Line Numbers
  1. encodeURIComponent('#path#')
Hey Acoder,

That was it, it just needed the quotes. THANK YOU, THANK YOU!!! Thank you so much for all your help, it is awesome to see it downloading and deleting files :).
Thank you again :),
Rach
Oct 27 '08 #107
acoder
16,027 Expert Mod 8TB
Oh, you're welcome! Glad it's working.
Oct 27 '08 #108

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David Barrett | last post by:
I'm proud to announce the completion of QwikiWiki v1.4.1, available for download now! QwikiWiki has the fastest installation, easiest syntax, and the fewest, highest-value features of any wiki...
2
by: Bob Greschke | last post by:
Does Text.delete(0.0, END) delete all of the tags too? Everything says it does not delete marks, but nothing about tags. Thanks! Bob
1
by: Ray | last post by:
Hello all, I am attempting to delete multiple rows from multiple tables as follows: DELETE FROM attachments,responses,response_lines WHERE attachments.id IN(2,7,11) AND...
4
by: Li Weng | last post by:
Hi, I have two questions: 1) If there are more than one attachments, can I still use urn:schema:httpmail:attachmentfilename to get the file names? How? Or I need to use X-MS-ENUMATTS method? ...
1
by: Karen Grube | last post by:
Hi! I hate to bother you all with this, but I don't know how best to approach a particular task. Here's the deal: Once a month I personally (that is, in my own personal inbox on my...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
3
by: Mufasa | last post by:
Does anybody have any code that would go out to an e-mail account (I'm using g-mail), get the e-mails and if there are any attachments, get those and save them on the local hard drive? I don't...
4
by: Seguros Catatumbo | last post by:
Hi guys, i am having trouble deleting a file after sending an email. The file is in use. Here's the code: String texto = "Test"; System.Net.Mail.SmtpClient smtp = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.