Re: [PHP-DB] Storing Images #2

2010-02-05 Thread Richard Quadling
On 5 February 2010 09:08, elk dolk  wrote:
>> --
>> > I have my photos in /public_html/img/gid directory and
>> with this path:
>> > > getImage.php the server displays the photos.
>> >
>> > Now if I put my photos outside of the public_html like
>> this:
>> > /hidden_images/img/gid
>> >
>> > what would be the correct path to the photos in the
>> getImage.php script?
>>
>> Do you mean what url? You'll need a script to pull them
>> from outside the document root. The advantage of this is you
>> can do authentication checks before displaying the image.
>> The disadvantage is the web-server isn't serving the images
>> directly so there will be a slow down.
>>
>> So you point your images to
>>
>> getimage.php?image=123456
>>
> ..
> thank you for your useful comment, but I mean what url should I use
> for img src instead of  src='http://www.mydomain.com/img/{$gid}/{$photoFileName}' in the getImage.php 
> script?
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


The whole point of putting the images _OUTSIDE_ of the web root is to
completely remove the possibility of having all your images downloaded
without any checks of who is doing it.

If I can enter the URL of the image directly, why would I pay you for
it (for example).

So, producing a symlink/alias of the images folder so that it DOES
exist within docroot is completely redundant.

Something like this is what I would expect your getImage.php script to be.




-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing Images #2

2010-02-05 Thread elk dolk
> --
> > I have my photos in /public_html/img/gid directory and
> with this path:
> >  getImage.php the server displays the photos.
> > 
> > Now if I put my photos outside of the public_html like
> this: 
> > /hidden_images/img/gid
> > 
> > what would be the correct path to the photos in the
> getImage.php script?
> 
> Do you mean what url? You'll need a script to pull them
> from outside the document root. The advantage of this is you
> can do authentication checks before displaying the image.
> The disadvantage is the web-server isn't serving the images
> directly so there will be a slow down.
> 
> So you point your images to
> 
> getimage.php?image=123456
> 
..
thank you for your useful comment, but I mean what url should I use
for img src instead of http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing Images #2

2010-02-04 Thread Chris

elk dolk wrote:

On 3 February 2010 16:07,   wrote:


I currently have all my images referenced by url in my database and stored
in a folder/s and I think I will keep it that way...


..


If you put the images OUTSIDE of the webroot/docroot/public_html

folder (whatever you have), then a user cannot directly navigate to
the file.

e.g.
 /home/sites/your_site/public_html/images/image1.jpg

 http://www.yoursite.com/images/image1.jpg would probably work.

But ...

/home/sites/your_site/public_html/getImage.php
/home/sites/your_site/hidden_images/image1.jpg


Now, there is no way I can load image1.jpg from my browser. I have to

use getImage.php, which I assume would require me to login or
authenticate myself in some way.
--
I have my photos in /public_html/img/gid directory and with this path:
Now if I put my photos outside of the public_html like this: 


/hidden_images/img/gid

what would be the correct path to the photos in the getImage.php script?


Do you mean what url? You'll need a script to pull them from outside the 
document root. The advantage of this is you can do authentication checks 
before displaying the image. The disadvantage is the web-server isn't 
serving the images directly so there will be a slow down.


So you point your images to

getimage.php?image=123456

and getimage.php does your authentication checks if necessary then pulls 
the image back using something like http://www.php.net/fpassthru


--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing Images #2

2010-02-04 Thread Jason Gerfen
If its outside the html root you would need to create a symlink pointing 
to the appropriate folder


%> ln -s /path/to/hidden /path/to/public *however this is very insecure

Then if your wise you could create a simple image serving script to 
prevent direct navigation by checking the referring page request vs. an 
array of allowed script names, the folder and filename being requested 
etc. Kind of like an intermediary to ensure your (*assumed world 
readable and writable) images directory is somewhat unusable except by 
your scripts.


If you did it in this manner you could simply call the image as you 
would regularly.. 


Of course this is all theoretical as I have never done this before but 
if you also block your upload script (*an assumption based on the 
question) you could limit it using apache hosts_allow and hosts_deny 
directives.


Or you could use your upload script to copy the files to the server, 
then once the application publishes the site you could use it to copy 
the image files from the writable directory (above the web root) into 
the public images directory.


The best method would require the following:
1. a sub domain with limited access using apaches hosts_allow and 
hosts_deny directives

2. a world read/writable folder located outside of the web root
3. script prevention by checking referring scripts as well as perhaps an 
internal allowed ip range directive
4. a command line, crontab entry to move image files from the world 
read/writable folder into the public/images folder


You should look into linux folder and file permissions vs. the user and 
group that is running as your web server. Just a few suggestions. Keep 
in mind that the only real way to keep your stuff secure is to cut the cord.


elk dolk wrote:

On 3 February 2010 16:07,   wrote:

  

I currently have all my images referenced by url in my database and stored
in a folder/s and I think I will keep it that way...



..

  

If you put the images OUTSIDE of the webroot/docroot/public_html


folder (whatever you have), then a user cannot directly navigate to
the file.

e.g.
 /home/sites/your_site/public_html/images/image1.jpg

 http://www.yoursite.com/images/image1.jpg would probably work.

But ...

/home/sites/your_site/public_html/getImage.php
/home/sites/your_site/hidden_images/image1.jpg

  

Now, there is no way I can load image1.jpg from my browser. I have to


use getImage.php, which I assume would require me to login or
authenticate myself in some way.
--
I have my photos in /public_html/img/gid directory and with this path:
Now if I put my photos outside of the public_html like this: 


/hidden_images/img/gid

what would be the correct path to the photos in the getImage.php script?





  

  



--
Jas


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-03 Thread Richard Quadling
On 3 February 2010 16:35, Karl DeSaulniers  wrote:
> Any pointers on where I can find a sample locking script.
> I may have artists editing files and that would be great to have a
> locking of the file while an artist is working on it so no one over writes
> each other.
> LMK,
> Thanks,
>
> Karl
>
> On Feb 3, 2010, at 10:31 AM, Richard Quadling wrote:
>
>> If you have any writers, then you need to introduce a locking
>> mechanism or some other protection.
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>

Take a read at what started in
http://marc.info/?l=php-db&m=126444533212143&w=2 and
http://marc.info/?l=php-db&m=126471476932749&w=2

I mention using a simple directory as a lock.

You can implement it in any way you want though.

If you already have a mechanism to stop multiple users from editing
the same image via a DB, then use that, but just store the image
outside of the web root.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-03 Thread Karl DeSaulniers

Any pointers on where I can find a sample locking script.
I may have artists editing files and that would be great to have a
locking of the file while an artist is working on it so no one over  
writes each other.

LMK,
Thanks,

Karl

On Feb 3, 2010, at 10:31 AM, Richard Quadling wrote:


If you have any writers, then you need to introduce a locking
mechanism or some other protection.


Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP-DB] Storing images

2010-02-03 Thread Richard Quadling
On 3 February 2010 16:22, Karl DeSaulniers  wrote:
> A..
> Very nice. I did not think of that.
> But lets say its a whole bunch of images and multiple people may be
> accessing them.
> Is it safe to have them accessing a directory outside the public_html
> directory?
> Thanks,
>
> Karl
>
> On Feb 3, 2010, at 10:14 AM, Richard Quadling wrote:
>
>> On 3 February 2010 16:07, Karl DeSaulniers  wrote:
>>>
>>> Thank you all for your numerous responses.
>>>
>>> I hear you loud and clear. I was wanting to see if it would be less of a
>>> burden on the server and secure my images better to put the images inside
>>> a
>>> database, but
>>> as you all have almost uniformly stated, this would not be the best
>>> situation.
>>> I currently have all my images referenced by url in my database and
>>> stored
>>> in a folder/s and I think I will keep it that way...
>>>
>>> Thanks for your 2 cents,
>>>
>>> :)
>>>
>>> Karl
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> If you put the images OUTSIDE of the webroot/docroot/public_html
>> folder (whatever you have), then a user cannot directly navigate to
>> the file.
>>
>> e.g.
>> /home/sites/your_site/public_html/images/image1.jpg
>>
>> http://www.yoursite.com/images/image1.jpg would probably work.
>>
>> But ...
>>
>> /home/sites/your_site/public_html/getImage.php
>> /home/sites/your_site/hidden_images/image1.jpg
>>
>> Now, there is no way I can load image1.jpg from my browser. I have to
>> use getImage.php, which I assume would require me to login or
>> authenticate myself in some way.
>>
>>
>> --
>> -
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>

If the file is outside of the docroot, then they _CANNOT_ access them.
There is no url to the image!

So, a script which examines the session to make sure the request is
valid is normally enough to restrict feeding the images to valid
users.

Multiple simultaneous readers are not a problem.

If you have any writers, then you need to introduce a locking
mechanism or some other protection.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-03 Thread Karl DeSaulniers

A..
Very nice. I did not think of that.
But lets say its a whole bunch of images and multiple people may be  
accessing them.
Is it safe to have them accessing a directory outside the public_html  
directory?

Thanks,

Karl

On Feb 3, 2010, at 10:14 AM, Richard Quadling wrote:

On 3 February 2010 16:07, Karl DeSaulniers   
wrote:

Thank you all for your numerous responses.

I hear you loud and clear. I was wanting to see if it would be  
less of a
burden on the server and secure my images better to put the images  
inside a

database, but
as you all have almost uniformly stated, this would not be the best
situation.
I currently have all my images referenced by url in my database  
and stored

in a folder/s and I think I will keep it that way...

Thanks for your 2 cents,

:)

Karl

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




If you put the images OUTSIDE of the webroot/docroot/public_html
folder (whatever you have), then a user cannot directly navigate to
the file.

e.g.
/home/sites/your_site/public_html/images/image1.jpg

http://www.yoursite.com/images/image1.jpg would probably work.

But ...

/home/sites/your_site/public_html/getImage.php
/home/sites/your_site/hidden_images/image1.jpg

Now, there is no way I can load image1.jpg from my browser. I have to
use getImage.php, which I assume would require me to login or
authenticate myself in some way.


--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php? 
c=ZEND002498&r=213474731

ZOPA : http://uk.zopa.com/member/RQuadling


Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP-DB] Storing images

2010-02-03 Thread Richard Quadling
On 3 February 2010 16:07, Karl DeSaulniers  wrote:
> Thank you all for your numerous responses.
>
> I hear you loud and clear. I was wanting to see if it would be less of a
> burden on the server and secure my images better to put the images inside a
> database, but
> as you all have almost uniformly stated, this would not be the best
> situation.
> I currently have all my images referenced by url in my database and stored
> in a folder/s and I think I will keep it that way...
>
> Thanks for your 2 cents,
>
> :)
>
> Karl
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

If you put the images OUTSIDE of the webroot/docroot/public_html
folder (whatever you have), then a user cannot directly navigate to
the file.

e.g.
/home/sites/your_site/public_html/images/image1.jpg

http://www.yoursite.com/images/image1.jpg would probably work.

But ...

/home/sites/your_site/public_html/getImage.php
/home/sites/your_site/hidden_images/image1.jpg

Now, there is no way I can load image1.jpg from my browser. I have to
use getImage.php, which I assume would require me to login or
authenticate myself in some way.


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-03 Thread Karl DeSaulniers

Thank you all for your numerous responses.

I hear you loud and clear. I was wanting to see if it would be less  
of a burden on the server and secure my images better to put the  
images inside a database, but
as you all have almost uniformly stated, this would not be the best  
situation.
I currently have all my images referenced by url in my database and  
stored in a folder/s and I think I will keep it that way...


Thanks for your 2 cents,

:)

Karl

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-03 Thread Patrick Price
I would say that only if this is going to be a very small project should you
think about storing the images in the db.  I had a contract job for a real
estate company that had stored all their images in the database.  They had
~25K rows of data where each image was ~5K and their website was going down
weekly.

I had to rewrite the entire image upload/retrieval system for their site to
change it to folder based storage.

Just my thoughts...

Thanks

patrick



On Wed, Feb 3, 2010 at 8:02 AM, Phpster  wrote:

> Sure is.  Save the data in a blob field. Lots of examples on the net on how
> to get it there and back out again.
>
> Note that you will also find arguments about whether or not to do it in the
> first place. I prefer not to, as it causes significant performance issues
> when the image table gets to a certain size.
>
> Bastien
>
> Sent from my iPod
>
>
> On Feb 3, 2010, at 2:37 AM, Karl DeSaulniers  wrote:
>
>  Hello List,
>> Forgive me if this is a noob question, but is it possible to fill a
>> database table with actual image data, IE a jpeg? And then call that data to
>> display the image?
>> Or is it better to just reference it stored on the server somewhere and
>> just put the url in the database?
>> Thanks,
>>
>> Karl DeSaulniers
>> Design Drumm
>> http://designdrumm.com
>>
>>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DB] Storing images

2010-02-03 Thread Phpster
Sure is.  Save the data in a blob field. Lots of examples on the net  
on how to get it there and back out again.


Note that you will also find arguments about whether or not to do it  
in the first place. I prefer not to, as it causes significant  
performance issues when the image table gets to a certain size.


Bastien

Sent from my iPod

On Feb 3, 2010, at 2:37 AM, Karl DeSaulniers   
wrote:



Hello List,
Forgive me if this is a noob question, but is it possible to fill a  
database table with actual image data, IE a jpeg? And then call that  
data to display the image?
Or is it better to just reference it stored on the server somewhere  
and just put the url in the database?

Thanks,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images

2010-02-02 Thread Karl DeSaulniers

Ok, now here is another question from what you stated.
Is there a way to compress the image data before storing, like a zip  
archive does to files?

Thanks for your response.

Karl


On Feb 3, 2010, at 1:45 AM, Chaitanya Yanamadala wrote:

It i possible to store the image in the database. But it will  
increase the database size.

So try referring the URL..


Karl DeSaulniers
Design Drumm
http://designdrumm.com



RE: [PHP-DB] storing images in database

2005-01-26 Thread Chip Wiegand
Thanks for all the tips guys. I'll keep the last couple for future 
reference.
--
Chip

Gareth Heyes <[EMAIL PROTECTED]> wrote on 01/26/2005 05:30:45 AM:

>  >> if(isset($_GET['id'])) {
>   >> $id=$_GET['id'];
>  >>  $query = "select bin_data, filetype from binary_data where id=$id";
> 
> This is a really bad example, anybody can inject your query with 
> malicious sql commands.
> Never trust user supplied data.
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] storing images in database

2005-01-26 Thread Bastien Koert
Yes, I totally agree. This was merely a sample code of how it could be done. 
Not a definitive code samples of how to do it securely. There should be way 
more validation, and better error handling too.

Bastien
From: Gareth Heyes <[EMAIL PROTECTED]>
To: php-db@lists.php.net
CC: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] storing images in database
Date: Wed, 26 Jan 2005 13:30:45 +
>> if(isset($_GET['id'])) {
 >> $id=$_GET['id'];
>>  $query = "select bin_data, filetype from binary_data where id=$id";
This is a really bad example, anybody can inject your query with malicious 
sql commands.
Never trust user supplied data.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] storing images in database

2005-01-26 Thread Gareth Heyes
>> if(isset($_GET['id'])) {
 >> $id=$_GET['id'];
>>  $query = "select bin_data, filetype from binary_data where id=$id";
This is a really bad example, anybody can inject your query with 
malicious sql commands.
Never trust user supplied data.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] storing images in database

2005-01-25 Thread Bastien Koert
Just to polish the topic off,  below are the two files that have been tested 
on my machine (xp, apache2, php 4.3.9, mysql4.0.1x)


require("conn.php");
//check to see if the id is passed
if(isset($_GET['id'])) {
 $id=$_GET['id'];
 $query = "select bin_data, filetype from binary_data where id=$id";
 //echo $query;
 $result = connect($query);
 $row = mysql_fetch_array($result);
 {
  $data = $row['bin_data'];
  $type = $row['filetype'];
 }
 if ($type=="pjpeg") $type = "jpeg";
 Header( "Content-type: $type");
 echo $data;
}
?>

// show_desc.php
require("conn.php");
 // you may have to modify login information for your database server
 $query = "select description, id from binary_data ";
 $result = connect($query);
 while ($rows = MYSQL_FETCH_ARRAY($result))
 {
 echo $rows['description'];
 echo "";
 echo "\n";
};
?>
And I used table structure
CREATE TABLE binary_data (
id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
description CHAR(50),
bin_data LONGBLOB,
filename CHAR(50),
filesize CHAR(50),
filetype CHAR(50)
);
hth
bastien
From: Chip Wiegand <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
CC: "PHP DB" 
Subject: RE: [PHP-DB] storing images in database
Date: Tue, 25 Jan 2005 12:57:40 -0800
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:46:12 PM:
> yes goes back to the whole header problem which is why you are here.
>
> If you could post the code, it would be simpler to help you...
>
> Bastien
This is in the main page -
%s", $row["text"]);
?>
and this is in a new included page -

$data = @MYSQL_RESULT($result,0,"image");
$type = @MYSQL_RESULT($result,0,"type");
Header( "Content-type: $type");
echo $data;
};
?>
The database connection statements are in an include file called at the
top of the main page. In the first statement shown above the alt text for
the image appears on the web page just fine, the image itself shows a
broken image icon. FWIW, I have the image stored in the database in a blob
field, is that correct?
--
Chip
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: RE: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 12:44:44 -0800
> >
> >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:39:15
PM:
> >
> > > Its not src='id=$id'> that will defnintely blow up
> > >
> > > echo '';
> > >
> > > where $id is the id of the record you are trying to get the image
to...
> > >
> > > Bastien
> >
> >So the code has to be a seperate included page I guess?
> >--
> >Chip
> >
> > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > >To: [EMAIL PROTECTED]
> > > >CC: php-db@lists.php.net
> > > >Subject: RE: [PHP-DB] storing images in database
> > > >Date: Tue, 25 Jan 2005 12:37:15 -0800
> > > >
> > > >Thanks Bastien,
> > > >In testing this I have added the code samples to a page and have it
> > > >working except the path statement is not correct. For now, I've
just
> >added
> > > >all the code to one page, rather than including a second page. The
> > > >statement - echo ''; is resulting in this error -
The
> > > >requested URL /id=$id was not found on this server. Any
suggestions?
> > > >Thanks,
> > > >Chip
> > > >
> > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005
09:45:39
> >AM:
> > > >
> > > > > the best way to do this is to move the image processing code to
a
> > > >separate
> > > > > page and include it like this
> > > > >
> > > > > echo '';
> > > > >
> > > > > then the image page looks like this:
> > > > >  > > > >
> > > > > if($_GET['id']) {
> > > > > $id = $_GET['id'];
> > > > > // you may have to modify login information for your database
> >server:
> > > > > @MYSQL_CONNECT("localhost","root","password");
> > > > >
> > > > > @mysql_select_db("binary_data");
> > > > >
> > > > > $query = "select bin_data,filetype from binary_data where
id=$id";
> > > > > $result = @MYSQL_QUERY($query);
> > > > >
> > > > > $data = @MYSQL_RESULT($result,0,"bin_data");
> > > > > $type = @MY

RE: [PHP-DB] storing images in database

2005-01-25 Thread Bastien Koert
Filesystem is easier, by far since it avoids the content header. Glad you 
solved it

bastien
From: Chip Wiegand <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
CC: "PHP DB" 
Subject: RE: [PHP-DB] storing images in database
Date: Tue, 25 Jan 2005 14:32:11 -0800
I have done it an easier way, and probably a better way all-around anyway.
I am storing the images in a directory and have the script call the
file/alt text/title text and a description text in a paragraph below the
image. It works quite well this way.
What I'm doing is on this home page there is a place for a 'hotspot', a
special mention area for the latest news about a particular item. So I
have a directory and in it will store an image file called 'latest.gif',
so any new image that gets put here will overwrite the existing image.
This will be fine for the purposes and the site.
Here is the code I have used -
%s", $row["alt-text"],
$row["title-text"], $row["desc-text"]);
   }
?>
I'm sure there are many ways to do this sort of thing, but this is quick
and easy, and works.
Thanks guys,
--
Chip
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 01:06:01 PM:
> And how are you feeding the $id?are you setting a value for that
> element?
>
> In the sample code the default is the record_id that corresponds back to
the
> id of the row with the image blob field.
>
> Bastien
>
>
>
>
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >CC: "PHP DB" 
> >Subject: RE: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 12:57:40 -0800
> >
> >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:46:12
PM:
> >
> > > yes goes back to the whole header problem which is why you are here.
> > >
> > > If you could post the code, it would be simpler to help you...
> > >
> > > Bastien
> >
> >This is in the main page -
> > >printf(" >images\">%s", $row["text"]);
> >?>
> >and this is in a new included page -
> > >if($_GET['id']) {
> >$id = $_GET['id'];
> >$query = "select * from hotspots where id=$id";
> >$result = @MYSQL_QUERY($query);
> >
> >$data = @MYSQL_RESULT($result,0,"image");
> >$type = @MYSQL_RESULT($result,0,"type");
> >
> >Header( "Content-type: $type");
> >echo $data;
> >};
> >?>
> >The database connection statements are in an include file called at the
> >top of the main page. In the first statement shown above the alt text
for
> >the image appears on the web page just fine, the image itself shows a
> >broken image icon. FWIW, I have the image stored in the database in a
blob
> >field, is that correct?
> >--
> >Chip
> >
> > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > >To: [EMAIL PROTECTED]
> > > >Subject: RE: [PHP-DB] storing images in database
> > > >Date: Tue, 25 Jan 2005 12:44:44 -0800
> > > >
> > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005
12:39:15
> >PM:
> > > >
> > > > > Its not src='id=$id'> that will defnintely blow up
> > > > >
> > > > > echo '';
> > > > >
> > > > > where $id is the id of the record you are trying to get the
image
> >to...
> > > > >
> > > > > Bastien
> > > >
> > > >So the code has to be a seperate included page I guess?
> > > >--
> > > >Chip
> > > >
> > > > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > > > >To: [EMAIL PROTECTED]
> > > > > >CC: php-db@lists.php.net
> > > > > >Subject: RE: [PHP-DB] storing images in database
> > > > > >Date: Tue, 25 Jan 2005 12:37:15 -0800
> > > > > >
> > > > > >Thanks Bastien,
> > > > > >In testing this I have added the code samples to a page and
have it
> > > > > >working except the path statement is not correct. For now, I've
> >just
> > > >added
> > > > > >all the code to one page, rather than including a second page.
The
> > > > > >statement - echo ''; is resulting in this
error -
> >The
> > > > > >requested URL /id=$id was not found on this server. Any
> >suggestions?
> > > > > >Thanks,
> > > > > &g

RE: [PHP-DB] storing images in database

2005-01-25 Thread Chip Wiegand
I have done it an easier way, and probably a better way all-around anyway. 
I am storing the images in a directory and have the script call the 
file/alt text/title text and a description text in a paragraph below the 
image. It works quite well this way.
What I'm doing is on this home page there is a place for a 'hotspot', a 
special mention area for the latest news about a particular item. So I 
have a directory and in it will store an image file called 'latest.gif', 
so any new image that gets put here will overwrite the existing image. 
This will be fine for the purposes and the site.
Here is the code I have used -
%s", $row["alt-text"], 
$row["title-text"], $row["desc-text"]); 
   } 
?>
I'm sure there are many ways to do this sort of thing, but this is quick 
and easy, and works.
Thanks guys,
--
Chip
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 01:06:01 PM:

> And how are you feeding the $id?are you setting a value for that 
> element?
> 
> In the sample code the default is the record_id that corresponds back to 
the 
> id of the row with the image blob field.
> 
> Bastien
> 
> 
> 
> 
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >CC: "PHP DB" 
> >Subject: RE: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 12:57:40 -0800
> >
> >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:46:12 
PM:
> >
> > > yes goes back to the whole header problem which is why you are here.
> > >
> > > If you could post the code, it would be simpler to help you...
> > >
> > > Bastien
> >
> >This is in the main page -
> > >printf(" >images\">%s", $row["text"]);
> >?>
> >and this is in a new included page -
> > >if($_GET['id']) {
> >$id = $_GET['id'];
> >$query = "select * from hotspots where id=$id";
> >$result = @MYSQL_QUERY($query);
> >
> >$data = @MYSQL_RESULT($result,0,"image");
> >$type = @MYSQL_RESULT($result,0,"type");
> >
> >Header( "Content-type: $type");
> >echo $data;
> >};
> >?>
> >The database connection statements are in an include file called at the
> >top of the main page. In the first statement shown above the alt text 
for
> >the image appears on the web page just fine, the image itself shows a
> >broken image icon. FWIW, I have the image stored in the database in a 
blob
> >field, is that correct?
> >--
> >Chip
> >
> > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > >To: [EMAIL PROTECTED]
> > > >Subject: RE: [PHP-DB] storing images in database
> > > >Date: Tue, 25 Jan 2005 12:44:44 -0800
> > > >
> > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 
12:39:15
> >PM:
> > > >
> > > > > Its not src='id=$id'> that will defnintely blow up
> > > > >
> > > > > echo '';
> > > > >
> > > > > where $id is the id of the record you are trying to get the 
image
> >to...
> > > > >
> > > > > Bastien
> > > >
> > > >So the code has to be a seperate included page I guess?
> > > >--
> > > >Chip
> > > >
> > > > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > > > >To: [EMAIL PROTECTED]
> > > > > >CC: php-db@lists.php.net
> > > > > >Subject: RE: [PHP-DB] storing images in database
> > > > > >Date: Tue, 25 Jan 2005 12:37:15 -0800
> > > > > >
> > > > > >Thanks Bastien,
> > > > > >In testing this I have added the code samples to a page and 
have it
> > > > > >working except the path statement is not correct. For now, I've
> >just
> > > >added
> > > > > >all the code to one page, rather than including a second page. 
The
> > > > > >statement - echo ''; is resulting in this 
error -
> >The
> > > > > >requested URL /id=$id was not found on this server. Any
> >suggestions?
> > > > > >Thanks,
> > > > > >Chip
> > > > > >
> > > > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005
> >09:45:39
> > > >AM:
> > > > > >
> > > > > > > the best way

Re: [PHP-DB] storing images in database

2005-01-25 Thread Martin Norland
Bastien Koert wrote:
Its not src='id=$id'> that will defnintely blow up
echo '';
where $id is the id of the record you are trying to get the image to...
Bastien
From: Chip Wiegand <[EMAIL PROTECTED]>
[snip]
In testing this I have added the code samples to a page and have it
working except the path statement is not correct. For now, I've just 
added
all the code to one page, rather than including a second page. The
statement - echo ''; is resulting in this error - The
requested URL /id=$id was not found on this server. Any suggestions?

  echo '$wont $output $variables $values $because $of $single $quotes!';
  // echo '';
  // echo '';
}
shed_light();
?>
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] storing images in database

2005-01-25 Thread Chip Wiegand
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:46:12 PM:

> yes goes back to the whole header problem which is why you are here.
> 
> If you could post the code, it would be simpler to help you...
> 
> Bastien

This is in the main page -
%s", $row["text"]);
?>
and this is in a new included page -

The database connection statements are in an include file called at the 
top of the main page. In the first statement shown above the alt text for 
the image appears on the web page just fine, the image itself shows a 
broken image icon. FWIW, I have the image stored in the database in a blob 
field, is that correct?
--
Chip

> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: RE: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 12:44:44 -0800
> >
> >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:39:15 
PM:
> >
> > > Its not src='id=$id'> that will defnintely blow up
> > >
> > > echo '';
> > >
> > > where $id is the id of the record you are trying to get the image 
to...
> > >
> > > Bastien
> >
> >So the code has to be a seperate included page I guess?
> >--
> >Chip
> >
> > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > >To: [EMAIL PROTECTED]
> > > >CC: php-db@lists.php.net
> > > >Subject: RE: [PHP-DB] storing images in database
> > > >Date: Tue, 25 Jan 2005 12:37:15 -0800
> > > >
> > > >Thanks Bastien,
> > > >In testing this I have added the code samples to a page and have it
> > > >working except the path statement is not correct. For now, I've 
just
> >added
> > > >all the code to one page, rather than including a second page. The
> > > >statement - echo ''; is resulting in this error - 
The
> > > >requested URL /id=$id was not found on this server. Any 
suggestions?
> > > >Thanks,
> > > >Chip
> > > >
> > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 
09:45:39
> >AM:
> > > >
> > > > > the best way to do this is to move the image processing code to 
a
> > > >separate
> > > > > page and include it like this
> > > > >
> > > > > echo '';
> > > > >
> > > > > then the image page looks like this:
> > > > >  > > > >
> > > > > if($_GET['id']) {
> > > > > $id = $_GET['id'];
> > > > > // you may have to modify login information for your database
> >server:
> > > > > @MYSQL_CONNECT("localhost","root","password");
> > > > >
> > > > > @mysql_select_db("binary_data");
> > > > >
> > > > > $query = "select bin_data,filetype from binary_data where 
id=$id";
> > > > > $result = @MYSQL_QUERY($query);
> > > > >
> > > > > $data = @MYSQL_RESULT($result,0,"bin_data");
> > > > > $type = @MYSQL_RESULT($result,0,"filetype");
> > > > >
> > > > > Header( "Content-type: $type");
> > > > > echo $data;
> > > > >
> > > > > };
> > > > > ?>
> > > > >
> > > > > bastien
> > > > >
> > > > >
> > > > >
> > > > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > > > >To: "PHP DB" 
> > > > > >Subject: [PHP-DB] storing images in database
> > > > > >Date: Tue, 25 Jan 2005 09:11:07 -0800
> > > > > >
> > > > > >I have stored a .jpg image in a database, then when I make a 
sql
> > > >statement
> > > > > >to display that image on a web page all I get is the cryptic 
code
> >in
> > > >place
> > > > > >of the image. I am storing it in a row configured as a blob, 
mime
> >type
> > > > > >image/jpeg and binary (using phpMyAdmin). What am I doing 
wrong?
> > > > > >Regards,
> > > > > >Chip
> > > > > >
> > > > > >--
> > > > > >PHP Database Mailing List (http://www.php.net/)
> > > > > >To unsubscribe, visit: http://www.php.net/unsub.php
> > > > > >
> > > > >
> > > > > --
> > > > > PHP Database Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > >
> > >
> > >
> >
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] storing images in database

2005-01-25 Thread Bastien Koert
And how are you feeding the $id?are you setting a value for that 
element?

In the sample code the default is the record_id that corresponds back to the 
id of the row with the image blob field.

Bastien


From: Chip Wiegand <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
CC: "PHP DB" 
Subject: RE: [PHP-DB] storing images in database
Date: Tue, 25 Jan 2005 12:57:40 -0800
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:46:12 PM:
> yes goes back to the whole header problem which is why you are here.
>
> If you could post the code, it would be simpler to help you...
>
> Bastien
This is in the main page -
%s", $row["text"]);
?>
and this is in a new included page -

$data = @MYSQL_RESULT($result,0,"image");
$type = @MYSQL_RESULT($result,0,"type");
Header( "Content-type: $type");
echo $data;
};
?>
The database connection statements are in an include file called at the
top of the main page. In the first statement shown above the alt text for
the image appears on the web page just fine, the image itself shows a
broken image icon. FWIW, I have the image stored in the database in a blob
field, is that correct?
--
Chip
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: RE: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 12:44:44 -0800
> >
> >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 12:39:15
PM:
> >
> > > Its not src='id=$id'> that will defnintely blow up
> > >
> > > echo '';
> > >
> > > where $id is the id of the record you are trying to get the image
to...
> > >
> > > Bastien
> >
> >So the code has to be a seperate included page I guess?
> >--
> >Chip
> >
> > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > >To: [EMAIL PROTECTED]
> > > >CC: php-db@lists.php.net
> > > >Subject: RE: [PHP-DB] storing images in database
> > > >Date: Tue, 25 Jan 2005 12:37:15 -0800
> > > >
> > > >Thanks Bastien,
> > > >In testing this I have added the code samples to a page and have it
> > > >working except the path statement is not correct. For now, I've
just
> >added
> > > >all the code to one page, rather than including a second page. The
> > > >statement - echo ''; is resulting in this error -
The
> > > >requested URL /id=$id was not found on this server. Any
suggestions?
> > > >Thanks,
> > > >Chip
> > > >
> > > >"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005
09:45:39
> >AM:
> > > >
> > > > > the best way to do this is to move the image processing code to
a
> > > >separate
> > > > > page and include it like this
> > > > >
> > > > > echo '';
> > > > >
> > > > > then the image page looks like this:
> > > > >  > > > >
> > > > > if($_GET['id']) {
> > > > > $id = $_GET['id'];
> > > > > // you may have to modify login information for your database
> >server:
> > > > > @MYSQL_CONNECT("localhost","root","password");
> > > > >
> > > > > @mysql_select_db("binary_data");
> > > > >
> > > > > $query = "select bin_data,filetype from binary_data where
id=$id";
> > > > > $result = @MYSQL_QUERY($query);
> > > > >
> > > > > $data = @MYSQL_RESULT($result,0,"bin_data");
> > > > > $type = @MYSQL_RESULT($result,0,"filetype");
> > > > >
> > > > > Header( "Content-type: $type");
> > > > > echo $data;
> > > > >
> > > > > };
> > > > > ?>
> > > > >
> > > > > bastien
> > > > >
> > > > >
> > > > >
> > > > > >From: Chip Wiegand <[EMAIL PROTECTED]>
> > > > > >To: "PHP DB" 
> > > > > >Subject: [PHP-DB] storing images in database
> > > > > >Date: Tue, 25 Jan 2005 09:11:07 -0800
> > > > > >
> > > > > >I have stored a .jpg image in a database, then when I make a
sql
> > > >statement
> > > > > >to display that image on a web page all I get is the cryptic
code
> >in
> > > >place
> > > > > >of the image. I am storing it in a row configured as a blob,
mime
> >type
> > > > > >image/jpeg and binary (using phpMyAdmin). What am I doing
wrong?
> > > > > >Regards,
> > > > > >Chip
> > > > > >
> > > > > >--
> > > > > >PHP Database Mailing List (http://www.php.net/)
> > > > > >To unsubscribe, visit: http://www.php.net/unsub.php
> > > > > >
> > > > >
> > > > > --
> > > > > PHP Database Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > >
> > >
> > >
> >
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] storing images in database

2005-01-25 Thread Bastien Koert
Its not src='id=$id'> that will defnintely blow up
echo '';
where $id is the id of the record you are trying to get the image to...
Bastien

From: Chip Wiegand <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
CC: php-db@lists.php.net
Subject: RE: [PHP-DB] storing images in database
Date: Tue, 25 Jan 2005 12:37:15 -0800
Thanks Bastien,
In testing this I have added the code samples to a page and have it
working except the path statement is not correct. For now, I've just added
all the code to one page, rather than including a second page. The
statement - echo ''; is resulting in this error - The
requested URL /id=$id was not found on this server. Any suggestions?
Thanks,
Chip
"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 09:45:39 AM:
> the best way to do this is to move the image processing code to a
separate
> page and include it like this
>
> echo '';
>
> then the image page looks like this:
> 
> if($_GET['id']) {
> $id = $_GET['id'];
> // you may have to modify login information for your database server:
> @MYSQL_CONNECT("localhost","root","password");
>
> @mysql_select_db("binary_data");
>
> $query = "select bin_data,filetype from binary_data where id=$id";
> $result = @MYSQL_QUERY($query);
>
> $data = @MYSQL_RESULT($result,0,"bin_data");
> $type = @MYSQL_RESULT($result,0,"filetype");
>
> Header( "Content-type: $type");
> echo $data;
>
> };
> ?>
>
> bastien
>
>
>
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: "PHP DB" 
> >Subject: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 09:11:07 -0800
> >
> >I have stored a .jpg image in a database, then when I make a sql
statement
> >to display that image on a web page all I get is the cryptic code in
place
> >of the image. I am storing it in a row configured as a blob, mime type
> >image/jpeg and binary (using phpMyAdmin). What am I doing wrong?
> >Regards,
> >Chip
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] storing images in database

2005-01-25 Thread Chip Wiegand
Thanks Bastien,
In testing this I have added the code samples to a page and have it 
working except the path statement is not correct. For now, I've just added 
all the code to one page, rather than including a second page. The 
statement - echo ''; is resulting in this error - The 
requested URL /id=$id was not found on this server. Any suggestions?
Thanks,
Chip

"Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/25/2005 09:45:39 AM:

> the best way to do this is to move the image processing code to a 
separate 
> page and include it like this
> 
> echo '';
> 
> then the image page looks like this:
>  
> if($_GET['id']) {
> $id = $_GET['id'];
> // you may have to modify login information for your database server:
> @MYSQL_CONNECT("localhost","root","password");
> 
> @mysql_select_db("binary_data");
> 
> $query = "select bin_data,filetype from binary_data where id=$id";
> $result = @MYSQL_QUERY($query);
> 
> $data = @MYSQL_RESULT($result,0,"bin_data");
> $type = @MYSQL_RESULT($result,0,"filetype");
> 
> Header( "Content-type: $type");
> echo $data;
> 
> };
> ?>
> 
> bastien
> 
> 
> 
> >From: Chip Wiegand <[EMAIL PROTECTED]>
> >To: "PHP DB" 
> >Subject: [PHP-DB] storing images in database
> >Date: Tue, 25 Jan 2005 09:11:07 -0800
> >
> >I have stored a .jpg image in a database, then when I make a sql 
statement
> >to display that image on a web page all I get is the cryptic code in 
place
> >of the image. I am storing it in a row configured as a blob, mime type
> >image/jpeg and binary (using phpMyAdmin). What am I doing wrong?
> >Regards,
> >Chip
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] storing images in database

2005-01-25 Thread Bastien Koert
you can not ouput html and binary data at the same time. you need to have 
image headers sent to the browser to show the image properly.

the best way to do this is to move the image processing code to a separate 
page and include it like this

echo '';
then the image page looks like this:

if($_GET['id']) {
$id = $_GET['id'];
// you may have to modify login information for your database server:
@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("binary_data");
$query = "select bin_data,filetype from binary_data where id=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo $data;
};
?>
bastien

From: Chip Wiegand <[EMAIL PROTECTED]>
To: "PHP DB" 
Subject: [PHP-DB] storing images in database
Date: Tue, 25 Jan 2005 09:11:07 -0800
I have stored a .jpg image in a database, then when I make a sql statement
to display that image on a web page all I get is the cryptic code in place
of the image. I am storing it in a row configured as a blob, mime type
image/jpeg and binary (using phpMyAdmin). What am I doing wrong?
Regards,
Chip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] storing images in database

2005-01-25 Thread Micah Stevens

Could be lots of things, improper/missing headers is most likely, although 
it's not clear from your statement if you're displaying the binary data 
directly in the page or are you calling an image output script in an image 
tag. (as you should)

Show some code and the answer will be clear. 

-Micah 

On Tuesday 25 January 2005 09:11 am, Chip Wiegand wrote:
> I have stored a .jpg image in a database, then when I make a sql statement
> to display that image on a web page all I get is the cryptic code in place
> of the image. I am storing it in a row configured as a blob, mime type
> image/jpeg and binary (using phpMyAdmin). What am I doing wrong?
> Regards,
> Chip

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] storing images in a table or in a directory

2003-08-20 Thread colbey

I store alot in databases..  when you deal with filesystem there can be
issues with multiple webservers (need replication using something like
rsync, etc)..   I've used the db/filesystem link method before aswell but
typically go with database nowdays..

You do have to query each time to get images out, be sure to look at
sending correct cache headers to ensure clients don't keep coming back, or
implement a caching system so that the webserver doesn't have to go back
to the database for a query each time an image is requested..



On Wed, 20 Aug 2003, hicham kersit wrote:

> Hi,
> I have to manage a large amount of images uploaded by users on my site.
> Using php/mysql I don't know if I should store the images in a directory
> within the server or in a dedicated table.
> What is the most suited method?
> Thanks, best regards.
>
>
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] storing images in a table or in a directory

2003-08-20 Thread Chris Payne
Hi there,

Why not do both?  Store the images themselves in a dir, but reference them
from a table, so that way you can control them pretty much totally via PHP
and MySQL.  You could them write a system to create thumbnails from selected
items in the database or delete certain images etc . easily, because
you'd have the filename/location etc . stored in the DB.

That's how I do it anyway, as then you don't have to query each image
uploaded everytime, as it queries while you are uploading the image and
stores stats such as location, size, type etc ... in the DB.

Just a thought :-)

Chris


> Hi,
> I have to manage a large amount of images uploaded by users on my site.
> Using php/mysql I don't know if I should store the images in a directory
> within the server or in a dedicated table.
> What is the most suited method?
> Thanks, best regards.
>
>
>
>
>
>
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Storing images in MySQL table

2003-02-20 Thread sumbry
> The only disadvantage i've had of storing images in DB instead of
> Filesystem, is that when you use a PHP script to output the image to a
> client browser, MSIE doesn't always accept a suggested filename so it
> might try and save it as "your-script.php?img=2".
>
> Other then that, keeping images in DB is a lot easier since you don't
> have to keep your DB in sync with Filesystems ie. Deleted records in DB,
> but images still exist.

A way I've gotten around this, is that when I dump images into a directory
for use by articles in my db, the filename is always name
$articleid.filename (since articles and pics are uploaded to the server
via php, this is easy to enforce).

Thus, when I do kill of articles and what not, I simply remove
$articleid.* from my images directory as well.

I would strongly argue against stuffing images into a database tho.
That's what filesystems are for, and they are way better at it.  The
overhead alone is reason enough to make you decide against it.

--
At no time is freedom of speech more precious than when a man
hits his thumb with a hammer. -- Marshall Lumsden
Sumbry][ <[EMAIL PROTECTED]>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Storing images in MySQL table

2003-02-19 Thread Len Sorensen
On Wed, Feb 19, 2003 at 11:07:28AM +0200, Corne' Cornelius wrote:
> The only disadvantage i've had of storing images in DB instead of 
> Filesystem, is that when you use a PHP script to output the image to a 
> client browser, MSIE doesn't always accept a suggested filename so it 
> might try and save it as "your-script.php?img=2".

Perhaps using the syntax 'your-script.php/imagename?otherparams' would
solve that.  It does for the few cell phones I have worked on serving
images to.  At least apache allows that syntax.

> Other then that, keeping images in DB is a lot easier since you don't 
> have to keep your DB in sync with Filesystems ie. Deleted records in DB, 
> but images still exist.

Certainly nice.  Now if only postgres had a nice way to dump/backup
BLOBs. :)

Len Sorensen

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Storing images in MySQL table

2003-02-19 Thread Corne' Cornelius
Milan,

The only disadvantage i've had of storing images in DB instead of 
Filesystem, is that when you use a PHP script to output the image to a 
client browser, MSIE doesn't always accept a suggested filename so it 
might try and save it as "your-script.php?img=2".

Other then that, keeping images in DB is a lot easier since you don't 
have to keep your DB in sync with Filesystems ie. Deleted records in DB, 
but images still exist.


[EMAIL PROTECTED] wrote:

Hi everybody,
	i want to store some articles and images to them in MySQL 
db. could you just give advice if it is better to store the image in BLOB 
or if to save on server and in db just have it's URL.


			Hi Milan


 





=Disclaimer and Confidentiality===
This message contains information intended for the perusal, and/or use (if so stated), by the stated addressee(s) only. The information is confidential and privileged. If you are not an intended recipient, do not peruse, use, disseminate, distribute, copy or in any manner rely upon  he information contained in this message (directly or indirectly). The sender and/or the entity represented by the sender shall not be held accountable in the event that this prohibition is disregarded. If you receive this message in error, notify the sender immediately by e-mail, fax or telephone representations contained in this message, whether express or implied, are those of the sender only, unless that sender expressly states them to be the views or representations of an entity or person, who shall be named by the sender and who the sender shall state to represent. No liability shall otherwise attach to any other entity or person. ==


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Storing images in a database table, should it be done?

2001-01-15 Thread Cal Evans

Generically speaking, when faced with the option of putting graphics in a
Blob field or putting a pointer to them and storing them on the file system,
I have always chosen to store a pointer in the database and store the image
on the file system.

Cal
http://www.calevans.com


-Original Message-
From: William Bailey [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 15, 2001 11:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Storeing images in a database table, should it be
done?


Currently working on a site that will enable a paintball (or other type)
team to have there own site on the net.

They will all follow the same format and was thinking about putting there
images into a database table. I'm not asking how to do it, just should i do
it and what performance impact will it have.

I'm just thinking that it will be easier to manage an admin system if
everything is in a database and will therefore not have to worry about file
permissions etc.

Thanks,
William.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]