AaronJ
|
| Posted: 07/31/2002, 11:57 AM |
|
Does anyone have an elegant solution in CCS for displaying images that are
stored as blobs in a database?
I have an existing solution in from CC using a seperate view.php (where img
link is src="view.php?id=xxx" ) file with an open event of:
*****
$id = get_param("id");
if (!$id) die("can't find image");
$db->query("select image,filetype from images where image_id=". $id);
if ($db->next_record()) {
$type = $db->f("filetype");
Header( "Content-type: $type");
Header ("Pragma: no-cache");
echo $db->f("image");
exit();
}
*******
However this code did not convert over to CCS at all. I have been unable to
rework it for CCS, and regardless, I think there must be a more elegant
inline solution. Seems like this should be a natural feature for CCS to have
builtin... it is just retrieving and display data from a
database...afterall.
Thanks for any help!
|
|
|
 |
AaronJ
|
| Posted: 08/02/2002, 7:18 PM |
|
Can't even tell if anyone saw this or cares.. since there wasn't any
responses but my less than elegant solution was to remove my view.php from
the world of CCS.
I have instead just place view.php into the project and let CCS copy it, but
of course, that's fine since there is no need to ever mod/generate this
file.
Exact code used (for other folks who want to use inline database
image/blobs):
<?
// Param: image_id
// Returns image db
// ie.. <img src="view.php&image_id=123">
define("RelativePath", ".");
include(RelativePath . "/Common.php");
$db = new clsDBcsp_database();
if (!$image_id) die("can't find image");
$db->query("select image,filetype from images where image_id=". $image_id);
if ($db->next_record()) {
$type = $db->f("filetype");
Header( "Content-type: $type");
Header ("Pragma: no-cache");
echo $db->f("image");
exit();
}
?>
"AaronJ" <aaronjudd@coolersites.com> wrote in message
news:ai9bvf$7pi$2@news.codecharge.com...
> Does anyone have an elegant solution in CCS for displaying images that are
> stored as blobs in a database?
>
> I have an existing solution in from CC using a seperate view.php (where
img
> link is src="view.php?id=xxx" ) file with an open event of:
> *****
> $id = get_param("id");
> if (!$id) die("can't find image");
>
> $db->query("select image,filetype from images where image_id=". $id);
> if ($db->next_record()) {
> $type = $db->f("filetype");
> Header( "Content-type: $type");
> Header ("Pragma: no-cache");
> echo $db->f("image");
> exit();
> }
> *******
> However this code did not convert over to CCS at all. I have been unable
to
> rework it for CCS, and regardless, I think there must be a more elegant
> inline solution. Seems like this should be a natural feature for CCS to
have
> builtin... it is just retrieving and display data from a
> database...afterall.
>
>
> Thanks for any help!
>
>
>
>
>
>
|
|
|
 |
AaronJ
|
| Posted: 08/04/2002, 5:33 PM |
|
BTW- if anyone is interested.. this took me a while to figure out. I wanted
a form that uploaded images, and other properties without major hacking to
the CCS generated record form. Here's what I did (PHP):
In HTML:
Added enctype="multipart/form-data" to the <form> tag.
Add form_data input :
<tr>
<td class="CSPFieldCaptionTD" nowrap>Upload File</td>
<td class="CSPDataTD"><input type="file" class="CSPInput"
maxlength="50" size="50" name="form_data" }> </td>
</tr>
In Form Data Properties added CustomInsert ( and Custom Update Events ) :
Added four params :
Field: filename
Parameter: $form_data_name / EXPRESSION
Default Value: $_FILES['form_data']['name']
Field: filetypeParameter: $form_data_type / EXPRESSION
Default Value: $_FILES['form_data']['type']
Field: image
Parameter: $form_data / EXPRESSION
Default Value: fread(fopen($_FILES['form_data']['tmp_name'],
"rb"),$_FILES['form_data']['size'])
Field: filesize
Parameter: $form_data_size / EXPRESSION
Default Value: $_FILES['form_data']['size']
WHAM... it works like a charm. Can be use for any type of uploads also.
I did a few more tricks on the update event, let me know if you need further
details... but this should work easy enough. Took my a while to figure this
out.. though.. Cheers.
-Aaron
"AaronJ" <aaronjudd@coolersites.com> wrote in message
news:aifeh1$aff$1@news.codecharge.com...
> Can't even tell if anyone saw this or cares.. since there wasn't any
> responses but my less than elegant solution was to remove my view.php from
> the world of CCS.
> I have instead just place view.php into the project and let CCS copy it,
but
> of course, that's fine since there is no need to ever mod/generate this
> file.
>
> Exact code used (for other folks who want to use inline database
> image/blobs):
>
>
>
> <?
> // Param: image_id
> // Returns image db
> // ie.. <img src="view.php&image_id=123">
>
>
> define("RelativePath", ".");
> include(RelativePath . "/Common.php");
>
> $db = new clsDBcsp_database();
>
> if (!$image_id) die("can't find image");
>
> $db->query("select image,filetype from images where image_id=".
$image_id);
>
> if ($db->next_record()) {
>
> $type = $db->f("filetype");
>
> Header( "Content-type: $type");
> Header ("Pragma: no-cache");
> echo $db->f("image");
> exit();
> }
> ?>
>
>
>
>
>
> "AaronJ" <aaronjudd@coolersites.com> wrote in message
>news:ai9bvf$7pi$2@news.codecharge.com...
> > Does anyone have an elegant solution in CCS for displaying images that
are
> > stored as blobs in a database?
> >
> > I have an existing solution in from CC using a seperate view.php (where
> img
> > link is src="view.php?id=xxx" ) file with an open event of:
> > *****
> > $id = get_param("id");
> > if (!$id) die("can't find image");
> >
> > $db->query("select image,filetype from images where image_id=". $id);
> > if ($db->next_record()) {
> > $type = $db->f("filetype");
> > Header( "Content-type: $type");
> > Header ("Pragma: no-cache");
> > echo $db->f("image");
> > exit();
> > }
> > *******
> > However this code did not convert over to CCS at all. I have been unable
> to
> > rework it for CCS, and regardless, I think there must be a more elegant
> > inline solution. Seems like this should be a natural feature for CCS to
> have
> > builtin... it is just retrieving and display data from a
> > database...afterall.
> >
> >
> > Thanks for any help!
> >
> >
> >
> >
> >
> >
>
>
|
|
|
 |
Steven Dowd
|
| Posted: 08/23/2002, 12:45 AM |
|
Just read your posts ad downloaded the file for this , seems a very simple
solution, I would never have managed to figure it so gracefully.
and with so little extra code.
Steven Dowd
"AaronJ" <aaronjudd@coolersites.com> wrote in message
news:aikh4q$4of$1@news.codecharge.com...
> BTW- if anyone is interested.. this took me a while to figure out. I
wanted
> a form that uploaded images, and other properties without major hacking to
> the CCS generated record form. Here's what I did (PHP):
>
>
> In HTML:
>
> Added enctype="multipart/form-data" to the <form> tag.
> Add form_data input :
> <tr>
> <td class="CSPFieldCaptionTD" nowrap>Upload File</td>
> <td class="CSPDataTD"><input type="file" class="CSPInput"
> maxlength="50" size="50" name="form_data" }> </td>
> </tr>
>
> In Form Data Properties added CustomInsert ( and Custom Update Events ) :
>
> Added four params :
>
> Field: filename
> Parameter: $form_data_name / EXPRESSION
> Default Value: $_FILES['form_data']['name']
>
> Field: filetypeParameter: $form_data_type / EXPRESSION
> Default Value: $_FILES['form_data']['type']
>
> Field: image
> Parameter: $form_data / EXPRESSION
> Default Value: fread(fopen($_FILES['form_data']['tmp_name'],
> "rb"),$_FILES['form_data']['size'])
>
> Field: filesize
> Parameter: $form_data_size / EXPRESSION
> Default Value: $_FILES['form_data']['size']
>
> WHAM... it works like a charm. Can be use for any type of uploads also.
>
> I did a few more tricks on the update event, let me know if you need
further
> details... but this should work easy enough. Took my a while to figure
this
> out.. though.. Cheers.
>
> -Aaron
>
>
>
>
> "AaronJ" <aaronjudd@coolersites.com> wrote in message
>news:aifeh1$aff$1@news.codecharge.com...
> > Can't even tell if anyone saw this or cares.. since there wasn't any
> > responses but my less than elegant solution was to remove my view.php
from
> > the world of CCS.
> > I have instead just place view.php into the project and let CCS copy it,
> but
> > of course, that's fine since there is no need to ever mod/generate this
> > file.
> >
> > Exact code used (for other folks who want to use inline database
> > image/blobs):
> >
> >
> >
> > <?
> > // Param: image_id
> > // Returns image db
> > // ie.. <img src="view.php&image_id=123">
> >
> >
> > define("RelativePath", ".");
> > include(RelativePath . "/Common.php");
> >
> > $db = new clsDBcsp_database();
> >
> > if (!$image_id) die("can't find image");
> >
> > $db->query("select image,filetype from images where image_id=".
> $image_id);
> >
> > if ($db->next_record()) {
> >
> > $type = $db->f("filetype");
> >
> > Header( "Content-type: $type");
> > Header ("Pragma: no-cache");
> > echo $db->f("image");
> > exit();
> > }
> > ?>
> >
> >
> >
> >
> >
> > "AaronJ" <aaronjudd@coolersites.com> wrote in message
> >news:ai9bvf$7pi$2@news.codecharge.com...
> > > Does anyone have an elegant solution in CCS for displaying images that
> are
> > > stored as blobs in a database?
> > >
> > > I have an existing solution in from CC using a seperate view.php
(where
> > img
> > > link is src="view.php?id=xxx" ) file with an open event of:
> > > *****
> > > $id = get_param("id");
> > > if (!$id) die("can't find image");
> > >
> > > $db->query("select image,filetype from images where image_id=". $id);
> > > if ($db->next_record()) {
> > > $type = $db->f("filetype");
> > > Header( "Content-type: $type");
> > > Header ("Pragma: no-cache");
> > > echo $db->f("image");
> > > exit();
> > > }
> > > *******
> > > However this code did not convert over to CCS at all. I have been
unable
> > to
> > > rework it for CCS, and regardless, I think there must be a more
elegant
> > > inline solution. Seems like this should be a natural feature for CCS
to
> > have
> > > builtin... it is just retrieving and display data from a
> > > database...afterall.
> > >
> > >
> > > Thanks for any help!
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>
|
|
|
 |
|