Help displaying swf stored in DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mostaman
Forum Newbie
Posts: 1
Joined: Wed May 16, 2007 4:42 pm

Help displaying swf stored in DB

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
maliskoleather
Forum Contributor
Posts: 155
Joined: Tue May 15, 2007 2:19 am
Contact:

Post 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...
Post Reply