Forum Moderators: coopster
i have a flash audio player embedded on my website next to a file upload section, so what is supposed to happen is the user uploads a file, this sets the cookie audioFileOne to the location of the file ie. audio/audio-1.mp3 then presses play to preview the audio.
I think to explain my problem i need to show you my code,
<script language="JavaScript" src="audio/audio-player.js"></script>
<object type="application/x-shockwave-flash" data="audio/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="audio/player.swf">
<param name="FlashVars" value="playerID=1&soundFile=<?php echo $audioFileOne; ?>">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
</object>
So the part that i am cant get working is this part soundFile=<?php echo $audioFileOne; ?>"> because when the page loads the variable $audioFileOne is blank.
does anyone know how i could fix this?
thanks for any help in advance
To get a cookie: $_COOKIE['name']
Session: $_SESSION['name']
more: $_GET['name'], $_POST['name']
Those are some ways you can retrieve a variable you are trying to pass between pages. If your using cookies just replace: <?php echo $_COOKIE['audioFileOne']; ?> or whatever your cookie is called.
It might be a little easier if you do this: <?=$_COOKIE['name']?> just makes it a little shorter nothing different really.
[edited by: PokeTech at 4:26 pm (utc) on June 22, 2009]
<script language="JavaScript" src="audio/audio-player.js"></script>
<object type="application/x-shockwave-flash" data="audio/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="audio/player.swf">
<param name="FlashVars" value="playerID=1&soundFile=<?=$_COOKIE['audioFileOne']?>">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
</object>
so the problem here is not so clear to me?
works for $_SESSION, $_POST, $_GET or any other array ;)
odds are then the cookie isn't being set properly
what's in this var - $cookie - though I imagine it's a fulename
maybe extand your setcookie to something like
setcookie("TestCookie", $cookie, time()+3600, "/", ".example.com");
it may make a difference, obviously change all the values to your own
<form action="upload/upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();" >
<input type="hidden" name="AudioFile-1" value=""/>
<p id="f1_upload_process"><!--Loading...--><br/><img src="loader.gif" /></p>
<p id="f1_upload_form" align="center">
<input name="myfile" type="file" size="30" />
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Upload" />
</label>
</p>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
</form>
then that form posts to this page upload.php where i set the cookie..
<?php
include("../include/globals.php");
// Edit upload location here
//$destination_path = getcwd().DIRECTORY_SEPARATOR;
$destination_path = "../audio/";
$result = 0;
$target_path = $destination_path . basename( $_FILES['myfile']['name']);
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$result = 1;
setcookie("audioFileOne", $target_path);
setcookie("TestCookie", $cookie, time()+3600, "/", ".example.com");
}
sleep(1);
?>
<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>
i have this
echo '<pre>';
print_r($_COOKIE);
echo '</pre>';
on the page and i am not seeing the new cookie value come in at all..
$_SESSION['views'] = 1; // store session data
echo "Pageviews = ". $_SESSION['views'];
this returned Pageviews = 1 at the top of the page but when i put the line
$_SESSION['views'] = 1; // store session data
into my usual spot "upload.php" page and put this line into the main page
echo "Pageviews = ". $_SESSION['views'];
I get this error Notice: Undefined variable: _SESSION in C:\Program Files\EasyPHP 3.0\www\sentientmis\survey-step2.php on line 71
this is getting fairly frustrating :)