473,435 Members | 1,581 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,435 software developers and data experts.

Download an image to local machine

Hi,

I want to download a chart which I created using cfchart to excel and save it to local machine. The problem I am experiencing is when I save it in local machine,image is getting expired. The code I used to download to excel is

Expand|Select|Wrap|Line Numbers
  1. <cfif IsDefined("Excellink")>
  2.     <cfheader name="Content-Disposition" value="filename=chart.xls">
  3.     <cfcontent type="application/msexcel">
  4.  
  5. <cfchart
  6.  
  7.                         format = "jpg"
  8.                         chartHeight = "300"
  9.                         chartWidth = "500"
  10.             style = "mystyle.xml"
  11.             showXGridlines = "no"
  12.                         showYGridlines = "yes"
  13.             seriesPlacement = "default"
  14.             foregroundColor = "black"
  15.                         dataBackgroundColor = "white"
  16.                         showBorder = "yes"
  17.                         font = "arial"
  18.                         fontSize = "10"
  19.                         fontBold = "no"
  20.                         fontItalic = "no"
  21.                         labelFormat = "number"
  22.                         xAxisTitle = "WEEK"
  23.                         yAxisTitle = "ORDERS"
  24.                         sortXAxis = "no"
  25.                         show3D = "no"
  26.                         rotated = "no"
  27.                         showLegend = "yes"
  28.                         tipStyle = "MouseOver"
  29.                         showMarkers = "yes"
  30.                         markerSize = "4" >
  31.  
  32.  
  33.                        <cfchartseries
  34.                         type="line"
  35.                         query="query1"
  36.                         itemColumn="WEEK"
  37.                         valueColumn="ITEMS"
  38.             seriesColor="7fff00"
  39.             markerStyle="triangle"
  40.             seriesLabel="ITEMS">
  41.                         </cfchartseries>  
  42. </cfchart>
  43. </cfif>
  44.  
  45.  
Can anybody help me?
Thanks
Resmi
Jan 22 '08 #1
12 5372
acoder
16,027 Expert Mod 8TB
Does it expire immediately or after some time?
Jan 22 '08 #2
Does it expire immediately or after some time?
It expires immediately. Once I save it to local machine and open it. It displays image expired.

Thanks
Resmi
Jan 22 '08 #3
acoder
16,027 Expert Mod 8TB
That's because the chart is stored in the cache and once the cache expires the image is no longer available. The image is not being stored in the Excel file - it's just a link. You can try copying the chart to another location outside the cache and link to that instead.
Jan 22 '08 #4
That's because the chart is stored in the cache and once the cache expires the image is no longer available. The image is not being stored in the Excel file - it's just a link. You can try copying the chart to another location outside the cache and link to that instead.

Hi,

I tried to save the image by using the following code

<cffile
action="WRITE"
file="mychart.jpg"
output="#myChart#">

I set name attribute of cfchart to myChart.
Then I tried to view image by <img src="new.jpg"> but it is not displayed.
I checked whether image is present in the location and it was present.
I also set debugging off by <cfsetting showdebugoutput="no"> . Still its not working.
Jan 23 '08 #5
acoder
16,027 Expert Mod 8TB
Try specifying the full path to the file:
Expand|Select|Wrap|Line Numbers
  1. <cffile 
  2.             action="WRITE" 
  3.             file="c:\images\mychart.jpg" 
  4.             output="#myChart#">
Also note that you're checking for new.jpg instead of mychart.jpg.
Jan 23 '08 #6
Try specifying the full path to the file:
Expand|Select|Wrap|Line Numbers
  1. <cffile 
  2.             action="WRITE" 
  3.             file="c:\images\mychart.jpg" 
  4.             output="#myChart#">
Also note that you're checking for new.jpg instead of mychart.jpg.
Hi,

I tried giving the whole path. Still when it retrieve the image is empty.
But image is present in the location.

new.jpg was a mistake and is corrected.
Thanks
Resmi
Jan 24 '08 #7
acoder
16,027 Expert Mod 8TB
Now use that image in the Excel file.
Jan 24 '08 #8
Now use that image in the Excel file.
Hi,

I am not able to retrieve that image.
Empty image is displayed

Resmi
Jan 24 '08 #9
Hi,

I am not able to retrieve that image.
Empty image is displayed

Resmi
Hi,

I found it is problem with path. Image is getting stored in default path and when I try to retrieve it is searching in current directory. I am not able to specify the default path. It is appending it to the URL

Resmi
Jan 24 '08 #10
acoder
16,027 Expert Mod 8TB
Use an absolute path. If you want the default directory, it will usually be the temp directory which you can get with getTempDirectory().
Jan 24 '08 #11
Use an absolute path. If you want the default directory, it will usually be the temp directory which you can get with getTempDirectory().
Thankyou acoder. With getTempDirectory() I am able to get temp directory and download as an image file. Only problem is I am not able to download as excel. When I download as excel it is giving binary format not image.

Resmi
Jan 25 '08 #12
acoder
16,027 Expert Mod 8TB
If you try any normal image (not one generated using cfchart), is it still in binary format?
Jan 25 '08 #13

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

Similar topics

0
by: Jake | last post by:
How can I force an image download with IE using ASP.net?? Here is the catch: the image I want to force a write with is located on another web server. I can only reference the image with a URL. ...
1
by: Manish Songar via .NET 247 | last post by:
(Type your message here) I am using asp.net. I am not storing image in sql server.I storeall the image in one folder. I want to access image from thatfolder to my client machine. Images folder...
0
by: Mark | last post by:
We're authoring a VS 2005 app that includes several EXE's and DLL's and also uses a COM component (a customer requirement). The COM component provides a graphic image to be used by the .NET app;...
2
by: Erphan Rajput | last post by:
Hi! Kindly tell me how to download/copy an image to local system using C#. for instance my application that is running on local network which is connected to internet... wants to download the...
24
by: TC | last post by:
Hi folks I want to enhance my website to distinguish "external" hyperlinks from "internal" ones. With that aim, I've written the following two small files for testing purposes: ...
7
by: clintonG | last post by:
To all Microsoft partners and customers who have been unable to download recently or access ASP.NET documentation from the msdn2 website and for all of those customers who have been lied to and...
15
by: Baron Samedi | last post by:
Every so often, I see someone wanting to prevent heir images being downloaded and the general consensus is "you can't". Now a friend has asked me to think some more about this, and I think that...
1
by: RN1 | last post by:
In an ASP.NET app, users can upload their files to a remote server as back-up. I want to give users the provision to download files that they have uploaded to the remote server to their local...
6
by: raymond_b_jimenez | last post by:
I need to download a file from an Intranet web site and feed it into a program on the PC where the browser is running. Browser is Internet Explorer. Both Javascript and VBscript are options. Which...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.