PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Inserting a blob
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Inserting a blob

Réponse
 
LinkBack Outils de la discussion
Vieux 15/10/2007, 18h29   #1
sophie_newbie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Inserting a blob

Hi guys, I'm looking to insert a file, which was uploaded from a web
form into a MySQL BLOB attribute in a database. The thing is I want to
be able to do it without first having to write the file to disk. What
I'm saying is that I don't want to use "INSERT INTO database (file)
values ('/uploaddir/file.dat')"

I know there must be another way of doing this because when I insert
data as a BLOB in PhpMyAdmin, I see that it doesn't insert a file
reference, rather a big long string that always starts with something
like "0x1f7645.....". I'd like to know what this string means and how
I can go about converting the uploaded files which are stored in
memory to a string like this and attatch them to the database without
having to write them to disk. The files are quite large so I want to
avoid doing this.

Thanks!

  Réponse avec citation
Vieux 15/10/2007, 18h51   #2
Good Man
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inserting a blob

sophie_newbie <paulgeeleher@gmail.com> wrote in
news:1192465740.221446.199280@v23g2000prn.googlegr oups.com:

> Hi guys, I'm looking to insert a file, which was uploaded from a web
> form into a MySQL BLOB attribute in a database. The thing is I want to
> be able to do it without first having to write the file to disk. What
> I'm saying is that I don't want to use "INSERT INTO database (file)
> values ('/uploaddir/file.dat')"
>
> I know there must be another way of doing this because when I insert
> data as a BLOB in PhpMyAdmin, I see that it doesn't insert a file
> reference, rather a big long string that always starts with something
> like "0x1f7645.....". I'd like to know what this string means and how
> I can go about converting the uploaded files which are stored in
> memory to a string like this and attatch them to the database without
> having to write them to disk. The files are quite large so I want to
> avoid doing this.
>
> Thanks!
>
>


I don't quite follow your question. The file has to be stored
*somewhere* - either in the regular OS file system, or in the database.

From your first paragraph, it seems like you don't want the file saved
on your system, but just in your database.

From your second paragraph, it seems like you want to store the file on
disk somewhere but just reference it's path in the database.

The value of your BLOB column ("0x1f7645...") is unprocessed binary data
- your actual image/file.

If you want to store just the path, change the column type to VARCHAR
and just store the final path to the file there.

Otherwise, restate your question?

  Réponse avec citation
Vieux 15/10/2007, 19h09   #3
lark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inserting a blob

== Quote from sophie_newbie (paulgeeleher@gmail.com)'s article
> Hi guys, I'm looking to insert a file, which was uploaded from a web
> form into a MySQL BLOB attribute in a database. The thing is I want to
> be able to do it without first having to write the file to disk. What
> I'm saying is that I don't want to use "INSERT INTO database (file)
> values ('/uploaddir/file.dat')"
> I know there must be another way of doing this because when I insert
> data as a BLOB in PhpMyAdmin, I see that it doesn't insert a file
> reference, rather a big long string that always starts with something
> like "0x1f7645.....". I'd like to know what this string means and how
> I can go about converting the uploaded files which are stored in
> memory to a string like this and attatch them to the database without
> having to write them to disk. The files are quite large so I want to
> avoid doing this.
> Thanks!



i think what you see in phpMyAdmin is a handle to a temporary file. the file has
to be written to disk, i believe before being inserted into the database. you can
also implement a way of writing to a temporary location and then insert to
database. Finally, you'd delete the file from disk.

--
POST BY: lark with PHP News Reader
  Réponse avec citation
Vieux 15/10/2007, 20h14   #4
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inserting a blob

lark wrote:
> == Quote from sophie_newbie (paulgeeleher@gmail.com)'s article
>> Hi guys, I'm looking to insert a file, which was uploaded from a web
>> form into a MySQL BLOB attribute in a database. The thing is I want
>> to be able to do it without first having to write the file to disk.
>> What I'm saying is that I don't want to use "INSERT INTO database
>> (file) values ('/uploaddir/file.dat')"
>> I know there must be another way of doing this because when I insert
>> data as a BLOB in PhpMyAdmin, I see that it doesn't insert a file
>> reference, rather a big long string that always starts with something
>> like "0x1f7645.....". I'd like to know what this string means and how
>> I can go about converting the uploaded files which are stored in
>> memory to a string like this and attatch them to the database without
>> having to write them to disk. The files are quite large so I want to
>> avoid doing this.
>> Thanks!

>
>
> i think what you see in phpMyAdmin is a handle to a temporary file.
> the file has to be written to disk, i believe before being inserted
> into the database. you can also implement a way of writing to a
> temporary location and then insert to database. Finally, you'd delete
> the file from disk.


No, what you see in phpMyAdmin is a hexadecimal representation of the file
contents.
See http://dev.mysql.com/doc/refman/5.0/...al-values.html


  Réponse avec citation
Vieux 15/10/2007, 22h53   #5
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inserting a blob

On Mon, 15 Oct 2007 09:29:00 -0700, sophie_newbie
<paulgeeleher@gmail.com> wrote:

>Hi guys, I'm looking to insert a file, which was uploaded from a web
>form into a MySQL BLOB attribute in a database. The thing is I want to
>be able to do it without first having to write the file to disk.


The form upload will write it to disk, if you like it or
not. That's just part of the HTTP protocol. When your CGI
or PHP script starts, the upload is already done, and the
file is in the configured upload directory.
You can then proceed to load the file in the BLOB column,
and delete the uploaded file from the upload directory.

HTH
Regards,
--
( Kees
)
c[_] Giving power and money to government is like giving
whiskey and car-keys to teenage boys. (PJ O'Rourke) (#291)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h43.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14306 seconds with 13 queries