Solved

Can I make this into a link as opposed to a forced download?

Posted on 2014-10-29
4
110 Views
Last Modified: 2014-10-29
I've made my CSV file and it is pristine, but rather than this:

$filename="results.csv";
header('Content-type:application/csv');
header('Content-Disposition: attachment; filename='.$filename);
echo $output;

I want to make "results.csv" a link as opposed to a forced download.

How?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Expert Comment

by:Chris Watson
ID: 40411263
Remove this line.

header('Content-Disposition: attachment; filename='.$filename);

Open in new window

0
 

Accepted Solution

by:
S. Rahul Bose earned 250 total points
ID: 40411273
Since the header has been set and it is echoed right at the beginning, you cannot add a link later on in the script.  This is because the server has already told your browser that a csv is going to arrive and not html.  Since link is part of html, your intended purpose cannot be achieved.

Instead, you could have a process_results.php file which contains the code you mentioned, and link process_results.php, which in turn will let your users to download results.csv.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40411317
Making it a 'link' means it will display in the browser.  That is not a good way to download it especially if it is a large file.
0
 

Author Closing Comment

by:brucegust
ID: 40411435
I kind of figured I as barking up the wrong tree, but wanted to have it confirmed so I wasn't wasting time.

Thanks!
1

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question