I'm trying to update an old flash gallery site of mine using php. I'm wondering how I can get a file name randomly from the folder that stores all of the flashs after the original flash has been middle mouse clicked. I'm new to php and I feel as if I have some things mixed up and I have gaps in my knowledge.
HTML
<?php include 'header.php'; ?>
<div id="flash-container">
<object id="flash-content" data="swfs/sunshine.swf" type="application/x-shockwave-flash"></object>
</div>
<?php include 'footer.php'; ?>
PHP
<?php
function random_flash($dir = 'swfs')
{
$files = glob($dir . '/*.*');
$file = array_rand($files);
return $files[$file];
}
?>
Javascript
$(document).ready(function () {
$("#flash-content").on('click', function (e) {
$.ajax({
type: "GET"
, url: "flash.php"
, data: {
fileName: "$file"
}
}).done(function (msg) {
alert("Data Saved: " + msg);
});
if (e.which == 2) {
e.preventDefault();
flash - container.innerHTML = '<object id="flashcontent" data="' + $file + '">' + '<param name="movie" type="application/x-shockwave-flash">' + '</object>';
}
});
});