Page 1 of 1

Help displaying swf stored in DB

Posted: Wed May 16, 2007 4:47 pm
by mostaman
Hello

Would you please help me to display a swf file that is stored in a database (blob).

let us say I can manage to echo $swf; which produces a screen full of wierd chars (binary data).

What I need to know is where to go from here! regarding properly retrving data & displaying it in php or html.

I am stuc with those two values in macromedia <object> ... </object>:

"Movie" VALUE=" ? "
"Src" VALUE="? "


Usually those will point to a file location. In this case the file is in the database.

sample code will be great help

Thanks

Posted: Wed May 16, 2007 5:07 pm
by feyd
The source location will need to point to a script that can retrieve the data once requested. It will need some identifier to pull the correct record, of course.

Posted: Wed May 16, 2007 6:12 pm
by maliskoleather
i do something simmilar using images... the concept is the same, you'd just have to modify the headers and stuff to match a swf file..

my code:
in the html page: (where # is the image id number)

Code: Select all

<img src="image_generator.php?id=#" />
image_generator.php:

Code: Select all

$data = doQuery("SELECT data,type,imagetype FROM banners WHERE id='".$_GET['id']."' LIMIT 0,1",3600);
    printbanner($data);
    // i should note that doQuery is a custom function that returns an associative array based off the SQL - its the same as mysql_query()

function printbanner($data){
    
    header('Content-type: '.$data['imagetype']);
    header('Expires: Tue, 22 May 1988 03:20:00 GMT');
    header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    header('Cache-Control: no-store, n0-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', false);
    header('Pragma: no-cache');
    
    echo($data['data']);
        
}
keep in mind, this is a copy-and-paste example, where i cut some irrelevent chunks out of the code... it could be alot more secure.. but this is just to give you a basic example of how to execute it...