Dreamweaver MX Server Behaviours, Dynamic Images ?
#1
Scooby Regular
Thread Starter
Anybody know of a server behaviour for Dreamweaver that allows me to take an image, taken from a RecordSet, and display it ? I've got a PHP file, reading in a BLOB object from a mySQL database, but I want to be able to display the object as an image.
I realise I could get my hands dirty and code it myself in the PHP, but wondered if the server behaviours had been written already by anybody in Dreamweaver.
I realise I could get my hands dirty and code it myself in the PHP, but wondered if the server behaviours had been written already by anybody in Dreamweaver.
#2
I thought this was the whole of point of dreamweaver doing the php code for you so you can just drag and drop?
(am working on something identical to you by the sound of it lol).
(am working on something identical to you by the sound of it lol).
#3
Forget Dreamweaver objects, just do it yourself. Anyway, if the PHP code Dreamweaver writes is like the ASP code it generates, then it's fit for the bin.
Just use this script to output an image:
img.php:
<?
if($_GET[id]) {
$link = mysql_connect ('localhost', 'user', 'pass');
mysql_select_db('db');
header("Content-Type: image/jpeg");
$imgquery = mysql_query("select the_binary_data from my_table where row_id = $_GET[id]") or die (mysql_error());
$data = mysql_fetch_row($imgquery);
echo $data[0];
}
?>
---------------------------------------------------------------
Then to output an image on a page just add image tags:
<img src="img.php?id=your_id_here">
[Edited by legacyPete - 10/29/2002 12:15:06 AM]
[Edited by legacyPete - 10/29/2002 12:34:47 AM]
Just use this script to output an image:
img.php:
<?
if($_GET[id]) {
$link = mysql_connect ('localhost', 'user', 'pass');
mysql_select_db('db');
header("Content-Type: image/jpeg");
$imgquery = mysql_query("select the_binary_data from my_table where row_id = $_GET[id]") or die (mysql_error());
$data = mysql_fetch_row($imgquery);
echo $data[0];
}
?>
---------------------------------------------------------------
Then to output an image on a page just add image tags:
<img src="img.php?id=your_id_here">
[Edited by legacyPete - 10/29/2002 12:15:06 AM]
[Edited by legacyPete - 10/29/2002 12:34:47 AM]
#4
Scooby Regular
Thread Starter
ptholt - problem with relying on drag and drop code is, if you don't have the behaviours pre-coded, your stuffed !
legacyPete - thanks for the example, using Dreamweaver server behaviours is only a temporary thing until I get around to writing some proper PHP to code up my website from a full database.
legacyPete - thanks for the example, using Dreamweaver server behaviours is only a temporary thing until I get around to writing some proper PHP to code up my website from a full database.
#5
I'd advice against storing the image in the database, and instead just storing the location of the file.
Here's why (ASP & MS SQL but principals still apply):
http://aspfaq.com/show.asp?id=2149
Here's why (ASP & MS SQL but principals still apply):
http://aspfaq.com/show.asp?id=2149
#6
Scooby Regular
Thread Starter
Cheers for that, AdrianFRST -
Looking at my own application, I think storing the images in the database is still valid. I'll always have a copy of the database on a local machine, hence a valid backup, and since the database is going to be used to drive a product based web site, it gives me greater flexibility then storing references to file images. Last thing I want to have to do is sort out where images are kept, while the reference is called, maintaining it all when it changes, etc etc.
One thing I hadn't considered was the potential 2GB limit - does anybody know if mySQL has this limitation ?
Looking at my own application, I think storing the images in the database is still valid. I'll always have a copy of the database on a local machine, hence a valid backup, and since the database is going to be used to drive a product based web site, it gives me greater flexibility then storing references to file images. Last thing I want to have to do is sort out where images are kept, while the reference is called, maintaining it all when it changes, etc etc.
One thing I hadn't considered was the potential 2GB limit - does anybody know if mySQL has this limitation ?
#7
Trending Topics
#8
Scooby Regular
Adrian - i've had a look at this ASPUpload thing for a while now, but cant really figure out what the thing is. From playing with it, it looks like it stores the images in the db as long binary data, which doesn't really alleviate the stored image problem.
The bit that confuses me is this. Say I create an admin section, where the user can upload an image for a new product. They generally upload HUGE files from digicams etc. I then want the image to be stored on the server, and be passed through a resize component to resize it to a set number of pixels/size. The web pages will then draw the images from the folder using the image name and location which is given to the product at runtime.
But where do you declare where the images are uploaded to, and what do you do about server usernames/passwords?
So how we do that then?
The bit that confuses me is this. Say I create an admin section, where the user can upload an image for a new product. They generally upload HUGE files from digicams etc. I then want the image to be stored on the server, and be passed through a resize component to resize it to a set number of pixels/size. The web pages will then draw the images from the folder using the image name and location which is given to the product at runtime.
But where do you declare where the images are uploaded to, and what do you do about server usernames/passwords?
So how we do that then?
#9
Scooby Regular
Thread Starter
legacyPete -
The section of code you've got above - should that be working ? I'm not convinced that this :-
img src="img.php?id=your_id_here...
:- is actually calling the php file img. All I seem to get is an image tag trying to draw the img.php file.
Could someone confirm/deny the syntax of the above code for me ?
Ta.
The section of code you've got above - should that be working ? I'm not convinced that this :-
img src="img.php?id=your_id_here...
:- is actually calling the php file img. All I seem to get is an image tag trying to draw the img.php file.
Could someone confirm/deny the syntax of the above code for me ?
Ta.
Thread
Thread Starter
Forum
Replies
Last Post
hardcoreimpreza
Computer & Technology Related
21
11 October 2015 03:40 PM