www.webdeveloper.com
Results 1 to 4 of 4

Thread: Assigning a file to a variable

  1. #1
    Join Date
    Feb 2012
    Posts
    102

    Question Assigning a file to a variable

    Hello,

    I am attempting to assign a file to a variable and the file that is assigned is based on wether a condition is one option or the other. Would I use fopen() to assign the file on my server to a variable in order to have the user download that file when they click the download now button or is there a better way to accomplish this?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,160
    It's not clear what you mean. You can load the contents of a file into a variable or you can set a variable to be the name of a file.

    It seems likely that assigning the name of the file to your variable is what you want in order to allow a user to download the file. The code that creates the download button then needs to include the value of the variable so it can be passed to the script that sends the file to the user.

  3. #3
    Join Date
    Feb 2012
    Posts
    102

    Question

    I created a unique id and then a URL with the unique id that points to the script that is the thank you page. What I was thinking is that I can have the download button be linked to the URL that links to the thank you page script which will contain validation of the unique id and headers to force the download to be saved to the users computer. The reason I was asking about assigning the file name to the variable was to use it as the readfile header when the download button is clicked.

    Does this make sense?

    Will it work?

  4. #4
    Join Date
    Feb 2012
    Posts
    102

    Question Is this correct syntax?

    Here is the code that I would like to use the fopen with:

    PHP Code:

    if ($r == 9.99) {
     
    $package fopen('/cover01.zip');
    } elseif (
    $r == 14.99) { 
     
    $package fopen('/cover02.zip');
    } else { 
    // Problem finding the order!
        
    trigger_error('The transaction could not be found in the table!');

    Is this correct syntax and the correct way to use it?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles