By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

Upload a file into DB

P: n/a
Hi,

how can i upload a file with PHP into my database, and allow a download
of the file on the frontend (sent to client). Do i upload then into a
BLOB field? And how to check for a max filesize (max. 1MB) and if its
bigger cancel operation.

thanks for your help
yavuz bogazci

Jun 29 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

yo*********@googlemail.com wrote:
how can i upload a file with PHP into my database, and allow a download
of the file on the frontend (sent to client). Do i upload then into a
BLOB field? And how to check for a max filesize (max. 1MB) and if its
bigger cancel operation.

Why don't you upload the file to some folder and then insert link of it
to DB?

Mehmet Zahit Ates

Jun 29 '06 #2

P: n/a

realmehmet wrote:
yo*********@googlemail.com wrote:
how can i upload a file with PHP into my database, and allow a download
of the file on the frontend (sent to client). Do i upload then into a
BLOB field? And how to check for a max filesize (max. 1MB) and if its
bigger cancel operation.

Why don't you upload the file to some folder and then insert link of it
to DB?

Mehmet Zahit Ates


to be os independent and easier backup of the running app.

greets
yavuz bogazci

Jun 29 '06 #3

P: n/a
PHP already provides the OS independence.

It is better practice to store a link in the DB and the file in the
file system.

Accessing the file is also faster, as it doesn't have to go through the
database.

Backing up shouldn't be an issue. Backups should be done by scripts,
at the most you should only have to click a button or run a command to
perform a back up.

yo*********@googlemail.com wrote:
realmehmet wrote:
yo*********@googlemail.com wrote:
how can i upload a file with PHP into my database, and allow a download
of the file on the frontend (sent to client). Do i upload then into a
BLOB field? And how to check for a max filesize (max. 1MB) and if its
bigger cancel operation.

Why don't you upload the file to some folder and then insert link of it
to DB?

Mehmet Zahit Ates


to be os independent and easier backup of the running app.

greets
yavuz bogazci


Jun 29 '06 #4

P: n/a
On 29 Jun 2006 02:54:36 -0700, "yo*********@googlemail.com"
<yo*********@googlemail.com> wrote:
how can i upload a file with PHP into my database, and allow a download
of the file on the frontend (sent to client). Do i upload then into a
BLOB field?
Yes, BLOB is the usual name for the appropriate data type. But it depends on
what database you're using.

For downloads you either stream it out as the results of a query, or you write
it to a file and let the webserver serve that file, using the filesystem as a
cache, but keeping the database as the master, so you only need to backup the
database and not the filesystem copy.
And how to check for a max filesize (max. 1MB) and if its
bigger cancel operation.


http://uk.php.net/manual/en/features.file-upload.php

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jun 29 '06 #5

P: n/a
On 29 Jun 2006 12:45:34 -0700, "Richard Levasseur" <ri********@gmail.com>
wrote:
to be os independent and easier backup of the running app.


It is better practice to store a link in the DB and the file in the
file system.

Accessing the file is also faster, as it doesn't have to go through the
database.

Backing up shouldn't be an issue. Backups should be done by scripts,
at the most you should only have to click a button or run a command to
perform a back up.


When you just store filenames, there's no transactional link between the
metadata in the database, and separate files on the filesystem, so it makes
writing the backup system behind the button more complicated to implement
correctly, particularly during hot backups.

Sometimes storing the files in the database along with its metadata, making it
easier to make self-consistent backups amongst other factors, offsets the
overheads. As with most things, it depends on what you're actually doing.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jun 29 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.