![]() |
MySQL Fieldtype :: MEDIUMBLOB
Hey guys,
I've been jerking around (no comment svp) with the MEDIUMBLOB field in MySQL. I've tried uploading a file, ... need I say files but I am not able to return any of them. Not a .exe or .jpg on display.When retrieving a JPEG file, I tried displaying with with first engaging the header("Content-type: image/jpeg"); but that didn't work.I asked my guru PHP mate but he didn't knew either or it took to long. Anyways, I just posted it. :-) Mark |
Using header() should be pretty much all you need to do.
For example: PHP Code:
Alan |
I directly uploaded it using phpMyAdmin. I hope that it works as well or else I am doing something horribly wrong. Meaning, it doesn't work.
Can you give me an example of some kind of form using the upload function like you just referenced? Thanks for the quick reply Alan, love it. |
Your form would look something like:
Code:
<form enctype="multipart/form-data" action="upload.php" method="post">Then in your upload script, you would have something like the following to insert the image to your database: PHP Code:
Alan |
I donīt know if iīm way of base with this statement.
But somewhere i read that you should use base64_encode() on BLOB or binary data before storing it in the database. And then ofcourse use base64_decode() when you get the data out from the database to display it, or download it or whatever. Could somebody of our gurus shed som light on this? :-D /EyeDentify |
base64'ing binary data is good practice if your data contains things like single quotes that would likey break your query.
It's also handy for database systems that don't support a BLOG type field like older version of Microsoft SQL server. In these cases, you can base64_encode() your file and insert it into a TEXT field instead. Alan |
| All times are GMT. The time now is 03:41 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0