Binary DB insertion using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Binary DB insertion using PHP

Post 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...
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post 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.
User avatar
gijs
Forum Commoner
Posts: 53
Joined: Wed Aug 28, 2002 4:05 am
Location: Belgium

Post 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
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post 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?
User avatar
gijs
Forum Commoner
Posts: 53
Joined: Wed Aug 28, 2002 4:05 am
Location: Belgium

Post 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
Post Reply