?
Solved

Use of Global Variable When Exporting / Downloading Content

Posted on 2011-05-02
1
Medium Priority
?
403 Views
Last Modified: 2012-05-11
Within an 'if' statement, I'm defining a variable that I'd like to be global. When I then export to text file for download, I'd like to use that variable to define the filename.

Not sure how to get this to work. Any assistance would be appreciated.

Here is some excerpt from what I currently have:

<?php
//
if( isset($_REQUEST['action']) && ( strval($_REQUEST['action']) == 'export') )      {
      header("Content-Type: application/txt");
      header("Content-Disposition: attachment; filename=$nameOfFile.xls");
}

if( $action != "export") {
      global $nameOfFile = "test.txt");
      ?><a href='?action=export'>Export</a><?php
}

if( $action == "export") {
      echo "This is just a test";
}
?>
0
Comment
Question by:deharvy
1 Comment
 
LVL 81

Accepted Solution

by:
arnold earned 2000 total points
ID: 35509836
What do you mean, are you trying to maintain unique filenames?
YOu can either store it in a database or use session.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

839 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