Page 1 of 1

Binary DB insertion using PHP

Posted: Wed Oct 02, 2002 1:53 pm
by Heavy
How do I continue with this:

Code: Select all

<form enctype="multipart/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file:
<input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
...to insert binary data into a MySQL-table using PHP?

Code: Select all

<?php
mysql_query("insert into tablename set binaryblob='$userfile'");
?>
...doesn't feel right...

Posted: Wed Oct 02, 2002 2:21 pm
by llimllib
The manual and user notes go into this in detail. Read them, and if you have trouble understanding them, post it back up here and we'll help you.

Posted: Wed Oct 02, 2002 3:45 pm
by gijs
Hi,

answered to the same type of question on this topic yesterday.

Simply check the article on the following url:

you'll be amased how sipmle it is ....

http://www.php4.com/forums/viewtopic.php?t=6

I've got it up and running as a newbie in less then 20 minutes ... and understanding how its works ...

HIH,

Gijs

Posted: Wed Oct 02, 2002 5:36 pm
by Heavy
HUH!
addslashes!
I never thought it would be that easy!

I do still wonder though, why you use that variable called $nodelist in the download.php script.
Is there an insert limit at 64k or what?

Posted: Thu Oct 03, 2002 1:10 am
by gijs
Hi Heavy,

told you, easy he 8).

But first: I'm not the author of this article. b0nfire is. Credit is due where credit is due :!:
So for further questions please referr to him.

I'll try to answer your question as good an bad as it goes: simply upload a file o lets say 200 kb and take a look at your filedata table.

You will notice that the masterid will have several file_id's.
That what it is suposed to do: it chops up the 200 kb in different peaces and stores them as separate records (in the blob field) in the table.
This is relative to the size limitations of the blob-field type and this way the flexibility as decribed in the article is obtained. So therefore there is no limit of the binary data to insert.

Glad to be of any help.

Gijs