|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
== 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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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) |
|
![]() |
| Outils de la discussion | |
|
|