RE: [PHP] Database and files

2002-04-24 Thread Richard Archer

At 3:19 PM +0200 22/4/02, Maxim Maletsky \(PHPBeginner.com\) wrote:

PostgreSQL is the best choice on my opinion. mySQL might fail on a large
DB.

I'd love to see an example or detailed anecdote of MySQL failing on a
large DB. I keep seeing comments saying MySQL is not robust, but in my
experience it's nearly bulletproof.

I have thrown some pretty large tasks at it, and even on my lowly
server it has handled everything with great agility.

The only times it has caused me problems are when:

1. a hard crash corrupted a table. Easily fixed once the problem was
pinpointed.

2. a mysql_pconnect escaped into a live site and every apache process
finished up holding open a connection to the database. This is nothing
less than a DB misconfiguration -- the default timeout for pconnections
is like 8 hours when 2 minutes would be more appropriate.

 ...R.

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




Re: [PHP] Database and files

2002-04-22 Thread Danny Shepherd

- Original Message -
From: David Russell [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, April 22, 2002 11:19 AM
Subject: [PHP] Database and files

 I have a database. It receives from my users files - which could be word
 documents, Adobe PDF files, text docs, anything...

 I store these in a BLOB field of the database.

If you get multiple requests for files, expect the db to fall over very
quickly - what's wrong with storing them on the filesystem and having a list
of them in the db?

[SNIP]

 Finds out the attachment mime type

 Sends a:

 Header(Content-type: mime-type);
 Header(Header(Content-Disposition: attachment;
filename=\File65.doc\ );
 Stream the contents of the blob to the browser.

WTF is up with Header(Header( ??
Surely this should be Header(Content-Disposition: attachment;
filename=\File65.doc\ );

Here's how I do it

header(content-type: $mime);
header(content-disposition: attachment; filename=\$displayName\);
echo $data;

One thing - note that that the header names and the actual mimetype are in
lower case. Got weird results with anything different.

HTH

Danny


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




Re: [PHP] Database and files

2002-04-22 Thread Richard Archer

At 12:19 PM +0200 22/4/02, David Russell wrote:

Header(Header(Content-Disposition: attachment; filename=\File65.doc\ );

That's not right. Must be a typo.

Make sure there is no output before the header function calls.

I use:

header(Content-type: application/octet-stream; name=\$fname\);
header(Content-Disposition: attachment; filename=\fname\);
header(Content-transfer-encoding: binary);

 ...R.

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




Re: [PHP] Database and files

2002-04-22 Thread Richard Archer

At 11:25 AM +0100 22/4/02, Danny Shepherd wrote:

If you get multiple requests for files, expect the db to fall over very
quickly - what's wrong with storing them on the filesystem and having a list
of them in the db?

If your DB falls over, get a better one. You wouldn't do this with
Access, but MySQL or PostgreSQL will handle this with no problems.

And storing them in the file system requires the web server process to
have write access to the directory in which the files are stored. And
so will any other users on that server. Security nightmare.


One thing - note that that the header names and the actual mimetype are in
lower case. Got weird results with anything different.

Interesting tip. I'll try that out on Mac IE which never did download
properly, IIRC.

 ...R.

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




Re: [PHP] Database and files

2002-04-22 Thread Danny Shepherd

- Original Message -
From: Richard Archer [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, April 22, 2002 11:40 AM
Subject: Re: [PHP] Database and files


 At 11:25 AM +0100 22/4/02, Danny Shepherd wrote:

 If you get multiple requests for files, expect the db to fall over very
 quickly - what's wrong with storing them on the filesystem and having a
list
 of them in the db?

 If your DB falls over, get a better one. You wouldn't do this with
 Access, but MySQL or PostgreSQL will handle this with no problems.

I've tried it in MySQL  - it didn't work - after inserting aprox 8Mbs of
data the MySQL server died with a 'server has gone away' message. And more
than 2-3 users symltaneously requesting files of only a few hundred kb
really seemed to kill performance.

 And storing them in the file system requires the web server process to
 have write access to the directory in which the files are stored. And
 so will any other users on that server. Security nightmare.

Having other users on your server is the security mightmare :) If you setup
the webserver to have its own user ('apache' instead of 'nobody') and only
allow the apache user access to those files, that should lessen the problem.

 One thing - note that that the header names and the actual mimetype are in
 lower case. Got weird results with anything different.

 Interesting tip. I'll try that out on Mac IE which never did download
 properly, IIRC.



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




Re: [PHP] Database and files

2002-04-22 Thread David Russell

Hi all,

Another bug bites the dust...

Thank you so much for your responses... 

As for the DB/filesystem issue, we need to be able to easily replicate this 
at some time to another server as the system may easily become a 
distributed intranet system. We made the decision to use a database as this 
is easier to move around - (Backup, copy, restore) (yes, yes I know about 
tar/gz etc, but this seemed the easiest at the time.

I am using InterBase as a database backend (actually IBFirebird) as this is 
a database system that we have been using extensively int eh office for a 
while.

I think it was the uppercase/lowercase thing that bit me - (the 
header(Header( thing was a type, decided to copy/paste after typing 
header( g

Thanks again

David R

Richard Archer wrote:

 At 11:25 AM +0100 22/4/02, Danny Shepherd wrote:
 
If you get multiple requests for files, expect the db to fall over very
quickly - what's wrong with storing them on the filesystem and having a
list of them in the db?
 
 If your DB falls over, get a better one. You wouldn't do this with
 Access, but MySQL or PostgreSQL will handle this with no problems.
 
 And storing them in the file system requires the web server process to
 have write access to the directory in which the files are stored. And
 so will any other users on that server. Security nightmare.
 
 
One thing - note that that the header names and the actual mimetype are in
lower case. Got weird results with anything different.
 
 Interesting tip. I'll try that out on Mac IE which never did download
 properly, IIRC.
 
  ...R.


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




RE: [PHP] Database and files

2002-04-22 Thread Maxim Maletsky \(PHPBeginner.com\)

Right, certain things is beter to keep in the Db. Keep present that the
file system is limited. You can't just have an unlimited amount of files
on the same directory.

PostgreSQL is the best choice on my opinion. mySQL might fail on a large
DB.


Sincerely,

Maxim Maletsky
Founder, Chief Developer

www.PHPBeginner.com   // where PHP Begins




-Original Message-
From: Richard Archer [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 22, 2002 12:41 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Database and files


At 11:25 AM +0100 22/4/02, Danny Shepherd wrote:

If you get multiple requests for files, expect the db to fall over very

quickly - what's wrong with storing them on the filesystem and having a

list of them in the db?

If your DB falls over, get a better one. You wouldn't do this with
Access, but MySQL or PostgreSQL will handle this with no problems.

And storing them in the file system requires the web server process to
have write access to the directory in which the files are stored. And so
will any other users on that server. Security nightmare.


One thing - note that that the header names and the actual mimetype are

in lower case. Got weird results with anything different.

Interesting tip. I'll try that out on Mac IE which never did download
properly, IIRC.

 ...R.

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



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