note 54910 added to function.unpack
| From: | Cristiano-finatofinato at yahoo dot com dot br | Date: | Tue, 19 Jul 2005 13:31:08 +0000 |
| Subject: | note 54910 added to function.unpack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92166@lists.php.net to get a copy of this message | ||
STORE FILES IN DATABASE SQL_SERVER
After days of research, I obtained a solution to my "big-problem" working with
php5/sqlserver/iis
//IN PHP.INI
//Valid range 0 - 2147483647. Default = 4096.
mssql.textsize = 2147483647
=============<INSERT>==================
$dataString = file_get_contents($_FILES['myfile']['tmp_name']);
$arrData = unpack("H*hex", $dataString);
$ds = "0x".$arrData['hex'];
$sql = "SET TEXTSIZE 2147483647";
mssql_query($sql, $conn);
$sql = " insert into table (myimage, name, extension) values (".$ds.",
'".$name."', '".$extension."') ";
mssql_query($sql, $conn);
=============</INSERT>==================
=============<RETRIEVE>==================
$sql = "SET TEXTSIZE 2147483647";
@mssql_query($sql, $conn);
$sql = " select myimage, name, extension from table ";
$rs = @mssql_query($sql, $conn);
header("Content-Disposition: attachment;
filename=".$rs['name'].".".$rs['extension']." ");
echo $rs['myfile'];
=============</RETRIEVE>==================
with apache does not work in some cases (work with txt files, but not work with pdf, .doc....), and
you will try to do another solution (the solution is more simple than this of sqlserver)
----
Manual Page -- http://www.php.net/manual/en/function.unpack.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54910
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54910&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54910&report=yes
Search -- http://master.php.net/manage/user-notes.php