Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created February 5, 2012 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radityopw/1745485 to your computer and use it in GitHub Desktop.
Save radityopw/1745485 to your computer and use it in GitHub Desktop.
<?php
$con = mssql_pconnect("server","user","pass");
if (!$con || !mssql_select_db('database', $con)) {
die('Unable to connect or select database!');
}
$fp = fopen($_FILES['upload']['tmp_name'], 'rb');
$file_content = fread($fp, filesize($_FILES['upload']['tmp_name']));
fclose($fp);
$data_cont = unpack("H*hex", $file_content);
$sql = "INSERT INTO FILES(name,type,data) values ('".$final_name."','".$_FILES['upload']["type"]."',0x".$data_cont['hex'].")";
$res = @mssql_query($sql,$con);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment