Connecting Tech Pros Worldwide Help | Site Map

Upload a file into DB

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 29th, 2006, 09:55 AM
yonthebeach@googlemail.com
Guest
 
Posts: n/a
Default Upload a file into DB

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


  #2  
Old June 29th, 2006, 10:25 AM
realmehmet
Guest
 
Posts: n/a
Default Re: Upload a file into DB


yonthebeach@googlemail.com wrote:[color=blue]
> 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.[/color]
Why don't you upload the file to some folder and then insert link of it
to DB?

Mehmet Zahit Ates

  #3  
Old June 29th, 2006, 11:05 AM
yonthebeach@googlemail.com
Guest
 
Posts: n/a
Default Re: Upload a file into DB


realmehmet wrote:[color=blue]
> yonthebeach@googlemail.com wrote:[color=green]
> > 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.[/color]
> Why don't you upload the file to some folder and then insert link of it
> to DB?
>
> Mehmet Zahit Ates[/color]

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

greets
yavuz bogazci

  #4  
Old June 29th, 2006, 07:45 PM
Richard Levasseur
Guest
 
Posts: n/a
Default Re: Upload a file into DB

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.

yonthebeach@googlemail.com wrote:[color=blue]
> realmehmet wrote:[color=green]
> > yonthebeach@googlemail.com wrote:[color=darkred]
> > > 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.[/color]
> > Why don't you upload the file to some folder and then insert link of it
> > to DB?
> >
> > Mehmet Zahit Ates[/color]
>
> to be os independent and easier backup of the running app.
>
> greets
> yavuz bogazci[/color]

  #5  
Old June 29th, 2006, 09:05 PM
Andy Hassall
Guest
 
Posts: n/a
Default Re: Upload a file into DB

On 29 Jun 2006 02:54:36 -0700, "yonthebeach@googlemail.com"
<yonthebeach@googlemail.com> wrote:
[color=blue]
>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?[/color]

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.
[color=blue]
>And how to check for a max filesize (max. 1MB) and if its
>bigger cancel operation.[/color]

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

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
  #6  
Old June 29th, 2006, 09:05 PM
Andy Hassall
Guest
 
Posts: n/a
Default Re: Upload a file into DB

On 29 Jun 2006 12:45:34 -0700, "Richard Levasseur" <richardlev@gmail.com>
wrote:
[color=blue][color=green]
>> to be os independent and easier backup of the running app.[/color]
>
>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.[/color]

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 :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.