Passing PHP Variables to different pages

Associate
Joined
27 Apr 2010
Posts
161
Hey guys.

I'm currently working on an application integrated into Facebook allowing people to create files using a form for user input in which they can post the files to facebook and also download them.

At present, files can be created, downloaded and posted to facebook.

The next part I want to figure out is how to allow users that have clicked on the posted link to also download these files and not just the user who has created it.

The problem is, I know what needs to happen, but I dont know how to make it happen!

Here is the code I have to download files:

PHP:
$myFile = $_GET['file'];

if(!file_exists($myFile))
{
	die('Error: File does not exist');
}
else
{
	header("Content-Description: File Transfer");
	header("Content-Disposition: attachment; filename=$myFile");
	header("Content-type: text/plain");
	readfile($myFile);
}

And here is the code used to reference my created file:

PHP:
<input type="button" onclick="window.location='downloadFile.php?file=<?php echo $gameconfigid;?>' " name="downloadBtn" value="Download">

(gameconfigid being the var that needs to be passed to the created file page)

Does anyone understand what I'm trying to achieve and if so... Could they tell me what needs to happen?
 
Sorry I should be more clear.

A form allows a user to create a file to be written to. When it is created, it copies some existing content from a file already on the server and it will write the user's input to the end of the file. It then closes the file handler and gives them the option to download it and post it to their news feed on facebook.

From facebook, when someone clicks the posted link, it will display the file that was created in an iframe on the page. There is a cancel button which will redirect them to the main page but I need a download button that will reference the file displayed in the iframe... Ultimately meaning other people can download the file.

Thanks again,
PrChaos.
 
I know the file path and it is inserted into a database upon creation with unique IDs.

It works perfectly on the page that is displayed after a form is submitted. I'm just not sure how to pass the gameconfigid variable to the other page to reference the generated file.

Is it possible to post links on this section of the form? I could show you what I'm trying to do.
 
I see. It was me that set up the server because I was having issues with permissions to create files so I'll change them up in a second.

I figured out how to do it and I've just tested it for different pages.

This is what I added

PHP:
<input type="button" onclick="window.location='downloadFile.php?file=<?php echo $row ['gameconfigid'];?>' " name="downloadBtn" value="Download">
 
Sorry just to clarify... If you're still reading this... What files are insecure? The only files I know that have permissions set to 777 are my game template files...
 
Back
Top Bottom