Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Sean C. McCarthy

Hi all,

If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
inserts in the DB is just the image's name, but not the file itself.

What is exactly the problem you are having with the class? Just a couple
days ago I had a problem uploading files into a MySQL DB because the
addslashes function. As I have seen in this code it also uses it. Your
problem is with getting corrupt data from the DB?

If it is this use base64_encode and base64_decode. This is a tip Chris
(only know his name) gave me as no solution for addslashes was given...
Thanks again Chris!!

Sean C. McCarthy
SCI, S.L. (www.sci-spain.com)


Richard Lynch wrote:
 
 Rasmus' classic Photo Album is still online with source code.
 
 Google:
 Rasmus Lerdorf and Photo Album
 
 --
 WARNING [EMAIL PROTECTED] address is an endangered species -- Use
 [EMAIL PROTECTED]
 Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
 Volunteer a little time: http://chatmusic.com/volunteer.htm
 - Original Message -
 From: Mike Gifford [EMAIL PROTECTED]
 Newsgroups: php.general
 To: [EMAIL PROTECTED]
 Sent: Tuesday, September 11, 2001 2:45 PM
 Subject: Uploading Photos to MySQL
 
  Hello,
 
  Has anyone developed another class for uploading images to a MySQL
 database?
 
  I downlaoded upload_db.zip from:
  http://circle.ch/scripts/
 
  as it was a phplib based and it looks like it should do what is required.
  However it doesn't seem to be working.
 
  Does anyone else have any good pointers to scripts to store jpg/png files
 in
  MySQL using PHP?
 
  Thanks.
 
  Mike
  --
  Mike Gifford, OpenConcept Consulting, http://openconcept.ca
  Offering everything your organization needs for an effective web site.
  Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
  In all things it is better to hope than to despair.Wolfgang von Goethe
 
 
 --
 PHP General 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 General 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]




Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Mike Gifford

Hi Sean,

Sean C. McCarthy wrote:
 If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
 inserts in the DB is just the image's name, but not the file itself.

I had trouble opening up the upload.php3 file in list six, so I couldn't verify 
by looking at the code.  Not sure if it was the javascript or what, but I 
couldn't open it.

 What is exactly the problem you are having with the class? Just a couple
 days ago I had a problem uploading files into a MySQL DB because the
 addslashes function. As I have seen in this code it also uses it. Your
 problem is with getting corrupt data from the DB?

Add slashes are included as the file is added to the array:
$this-daten[image] = addslashes(fread(fopen($userfile, r), 
filesize($userfile)));

Some content almost gets inserted.  However it only gets as far as:
Content-Type: image/jpeg ÿØÿà

The image filed is just a blob

 If it is this use base64_encode and base64_decode. This is a tip Chris
 (only know his name) gave me as no solution for addslashes was given...
 Thanks again Chris!!

Ok..  This is getting better..

http://php.net/manual/en/function.base64-encode.php
$this-daten[image] = addslashes(base64_encode(
fread(fopen($userfile, r), filesize($userfile;

gives me quite a lot more information.  Even looks like when I upload different 
images, that it is different information (unlike previous attempts)

Unfortunately, it still isn't producing the graphic that I'm looking for... 
Hmm..

I get raw code easily enough:
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18

Which is generated by:
mysql_connect($DBHOST, $DBUSER, $DBPASS);
mysql_select_db($DATABASE);
$resultset = mysql_query($query);
$query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
$resultset = mysql_query($query);
print(stripslashes(base64_decode(mysql_result($resultset, 0, Image;

So I couldn't either view the file here..  or within a SRC=.  See:
http://pgs.ca/WLP/profiles/test.html

Also thanks for providing the direct URL for :Rasmus' classic Photo Album is still 
online with source code.
Google:
Rasmus Lerdorf and Photo Album


The google reference was a bit indirect (but it got to the same place too). 
Thanks Richard for this.  Although I did have problems actually viewing the script.

Mike


- Original Message -
From: Mike Gifford [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, September 11, 2001 2:45 PM
Subject: Uploading Photos to MySQL


Hello,

Has anyone developed another class for uploading images to a MySQL

database?

I downlaoded upload_db.zip from:
http://circle.ch/scripts/

as it was a phplib based and it looks like it should do what is required.
However it doesn't seem to be working.

Does anyone else have any good pointers to scripts to store jpg/png files

in

MySQL using PHP?

Thanks.

Mike
--
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
In all things it is better to hope than to despair.Wolfgang von Goethe


--
PHP General 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]

 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Regarding Sept 11, http://www.fgcquaker.org/statement091101.html
In all things it is better to hope than to despair.Wolfgang von Goethe


-- 
PHP General 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]




Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Sean C. McCarthy

Mike Gifford wrote:
 
 Hi Sean,
 
 Sean C. McCarthy wrote:
  If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
  inserts in the DB is just the image's name, but not the file itself.
 
 I had trouble opening up the upload.php3 file in list six, so I couldn't verify
 by looking at the code.  Not sure if it was the javascript or what, but I
 couldn't open it.

I'll send you the code at a separate message, but just look at the
tables definitions. There are no blob columns. 

 
  What is exactly the problem you are having with the class? Just a couple
  days ago I had a problem uploading files into a MySQL DB because the
  addslashes function. As I have seen in this code it also uses it. Your
  problem is with getting corrupt data from the DB?
 
 Add slashes are included as the file is added to the array:
 $this-daten[image] = addslashes(fread(fopen($userfile, r),
 filesize($userfile)));
 
 Some content almost gets inserted.  However it only gets as far as:
 Content-Type: image/jpeg ÿØÿà
 
 The image filed is just a blob
 

Correct! I tried the same but with PDF files. The problem I had was that
stripslashes and stripcslashes were not working as the manual said. When
I had one \ addslashes() gave me \\ (comfirmed at the DB) but
stripslashes() gave me a big nothing striping everything.

  If it is this use base64_encode and base64_decode. This is a tip Chris
  (only know his name) gave me as no solution for addslashes was given...
  Thanks again Chris!!
 
 Ok..  This is getting better..
 
 http://php.net/manual/en/function.base64-encode.php
 $this-daten[image] = addslashes(base64_encode(fread(fopen($userfile, r), 
filesize($userfile;

Just 

$this-daten[image] = 
base64_encode(fread(fopen($userfile, r), filesize($userfile)));


The special chars in RFC2045 are from
http://www.ietf.org/rfc/rfc2045.txt?number=2045 :

 tspecials :=  ( / ) /  /  / @ /
   , / ; / : / \ / 
   / / [ / ] / ? / =
   ; Must be in quoted-string,
   ; to use within parameter values

Ok _ is not there... but anyway you are not going to make searches
with  ... like 'something_' 

 
 gives me quite a lot more information.  Even looks like when I upload different
 images, that it is different information (unlike previous attempts)
 
 Unfortunately, it still isn't producing the graphic that I'm looking for...
 Hmm..
 
 I get raw code easily enough:
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18
 
 Which is generated by:
 mysql_connect($DBHOST, $DBUSER, $DBPASS);
 mysql_select_db($DATABASE);
 $resultset = mysql_query($query);
 $query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
 $resultset = mysql_query($query);
 print(stripslashes(base64_decode(mysql_result($resultset, 0, Image;
 
 So I couldn't either view the file here..  or within a SRC=.  See:
 http://pgs.ca/WLP/profiles/test.html
 
 Also thanks for providing the direct URL for :Rasmus' classic Photo Album is still 
online with source code.
 Google:
 Rasmus Lerdorf and Photo Album

Have you forgot to add:

header (Content-Type: image/jpeg);

just before the print? If you have the type will be text/plain (or
text/html or something). Add it just before anything gets outputed.

doing a wget -s I got the replies from your scripts like:

Content-Type: text/html
Content-Type: image/jpeg



No idea about this...

Sean C. McCarthy
SCI, S.L. (www.sci-spain.com)

-- 
PHP General 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]




Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Mike Gifford

Hi Sean,

Sorry for the delay with this..  Been a rather busy month..  However your help 
on this project has been very useful..

Sean C. McCarthy wrote:
  Mike Gifford wrote:
 Sean C. McCarthy wrote:
 If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
 inserts in the DB is just the image's name, but not the file itself.
 I had trouble opening up the upload.php3 file in list six, so I couldn't verify
 by looking at the code.  Not sure if it was the javascript or what, but I
 couldn't open it.
  I'll send you the code at a separate message, but just look at the
  tables definitions. There are no blob columns.

It is good to look at this code (not sure if Mozilla under Linux didn't like
the javascript, but glad others could see it).

You are right in that there are no blob files in it..  However, i wasn't
starting from that file.  Rather from a phplib class that was posted right here:
http://circle.ch/scripts/

 What is exactly the problem you are having with the class? Just a couple
 days ago I had a problem uploading files into a MySQL DB because the
 addslashes function. As I have seen in this code it also uses it. Your
 problem is with getting corrupt data from the DB?
 Add slashes are included as the file is added to the array:
 $this-daten[image] = addslashes(fread(fopen($userfile, r),
 filesize($userfile)));
 Some content almost gets inserted.  However it only gets as far as:
 Content-Type: image/jpeg ÿØÿà
 The image filed is just a blob
  Correct! I tried the same but with PDF files. The problem I had was that
  stripslashes and stripcslashes were not working as the manual said. When
  I had one \ addslashes() gave me \\ (comfirmed at the DB) but
  stripslashes() gave me a big nothing striping everything.

I shouldn't need to use this command should I?
http://php.net/manual/en/function.addcslashes.php

I've used stripslashes before effectively in other pieces of code..

 If it is this use base64_encode and base64_decode. This is a tip Chris
 (only know his name) gave me as no solution for addslashes was given...
 Thanks again Chris!!
 Ok..  This is getting better..
 http://php.net/manual/en/function.base64-encode.php
 $this-daten[image] = addslashes(base64_encode(fread(fopen($userfile, 
r), filesize($userfile;
  Just
  $this-daten[image] =
   base64_encode(fread(fopen($userfile, r), filesize($userfile)));

Ok..  I've modified this..

  The special chars in RFC2045 are from
  http://www.ietf.org/rfc/rfc2045.txt?number=2045 :
   tspecials :=  ( / ) /  /  / @ /
 , / ; / : / \ / 
 / / [ / ] / ? / =
 ; Must be in quoted-string,
 ; to use within parameter values
  Ok _ is not there... but anyway you are not going to make searches
  with  ... like 'something_' 

Must admit that I've been thrown by this one..  I've got no idea what's up with 
this..

 gives me quite a lot more information.  Even looks like when I upload different
 images, that it is different information (unlike previous attempts)
 Unfortunately, it still isn't producing the graphic that I'm looking for...
 Hmm..
 I get raw code easily enough:
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18
 Which is generated by:
 mysql_connect($DBHOST, $DBUSER, $DBPASS);
 mysql_select_db($DATABASE);
 $resultset = mysql_query($query);
 $query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
 $resultset = mysql_query($query);
 print(stripslashes(base64_decode(mysql_result($resultset, 0, Image;
 So I couldn't either view the file here..  or within a SRC=.  See:
 http://pgs.ca/WLP/profiles/test.html
  Have you forgot to add:
  header (Content-Type: image/jpeg);

You are right..  I had commented this out because I was getting an error that 
the header was already loaded..  I figured since I saw that in the database as 
well that it had been inserted and was now redundant.

  just before the print? If you have the type will be text/plain (or
  text/html or something). Add it just before anything gets outputed.

So you want the new code to look like this (for what is now 
http://pgs.ca/WLP/profiles/getimage-simple.php3):

mysql_connect($DBHOST, $DBUSER, $DBPASS);
mysql_select_db($DATABASE);
$resultset = mysql_query($query);   
header(Content-type:  image/jpeg);
$query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
$resultset = mysql_query($query);
print(base64_decode(mysql_result($resultset, 0, Image)));


Hadn't done the following before:

  doing a wget -s I got the replies from your scripts like:
  Content-Type: text/html
  Content-Type: image/jpeg
  
  No idea about this...

Seems like taking out the add/remove slashes has elminated it from here:

[mike@office admin]$ wget -s 
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=20

[PHP] Re: Uploading Photos to MySQL

2001-09-11 Thread Richard Lynch

Rasmus' classic Photo Album is still online with source code.

Google:
Rasmus Lerdorf and Photo Album

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Mike Gifford [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, September 11, 2001 2:45 PM
Subject: Uploading Photos to MySQL


 Hello,

 Has anyone developed another class for uploading images to a MySQL
database?

 I downlaoded upload_db.zip from:
 http://circle.ch/scripts/

 as it was a phplib based and it looks like it should do what is required.
 However it doesn't seem to be working.

 Does anyone else have any good pointers to scripts to store jpg/png files
in
 MySQL using PHP?

 Thanks.

 Mike
 --
 Mike Gifford, OpenConcept Consulting, http://openconcept.ca
 Offering everything your organization needs for an effective web site.
 Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
 In all things it is better to hope than to despair.Wolfgang von Goethe



-- 
PHP General 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]