Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Fileuploads into SQL


Message #1 by Zeus <techzeus@p...> on Wed, 04 Jul 2001 21:00:08 +0800
Any tutorials or examples on fileuploading into SQL database?


At 12:24 PM 7/4/01 -0500, you wrote:

>I think the easiest way would be to upload the files in binary, and then
>just save them in the mysql database in a blob or long blob field.
>----- Original Message -----
>From: "Bob Page" <bpage@w...>
>To: "professional php" <pro_php@p...>
>Sent: Wednesday, July 04, 2001 10:40 AM
>Subject: [pro_php] Re: Fileuploads into SQL
>
>
> >
> >
> > > Hi Zeus,
> > >  I don't know about your first problem, but I also needed to
> > > upload files before to a MySQL database (images
> > > actually) but I couldn't figure out a way to do it (I didn't
> > > think of asking a mailing list) so instead I uploaded the files
> > > to a directory and copied the filenames into the database,
> > > and then referenced them that way. I'd love to here of a
> > > way to copy actual files to the database, if anyone knows it.
> > > Take it easy, Emmet
> >
> > Well,  I haven't actually attempted it but 3.23.0 and higher has a
> > function for that:
> >
> > http://www.mysql.com/doc/S/t/String_functions.html
> >
> > Look for the function  "load_file".  In fact, here is the short man
> > description:
> >
> > "This function is multi-byte safe.
> > LOAD_FILE(file_name)
> > Reads the file and returns the file contents as a string. The file must
> > be on the server, you must specify the full pathname to the file, and
> > you must have the file privilege. The file must be readable by all and
> > be smaller than max_allowed_packet. If the file doesn't exist or can't
> > be read due to one of the above reasons, the function returns NULL:
> > mysql> UPDATE table_name
> >            SET blob_column=LOAD_FILE("/tmp/picture")
> >            WHERE id=1;"
> >
> > You would do the reverse by using SELECT ... INTO OUTFILE or maybe INTO
> > DUMPFILE (I think).
> >
> > HTH,
> >
> > B.Page
> >
> >

  Return to Index