Advertisement
Advertisement
| 07.24.2008 at 07:53AM PDT, ID: 23592298 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: |
*****************************<index.php>
<?php
//---------------------
// Connect to Database
//---------------------
include('db_config.php');
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$handle = fopen($tmpName, 'r');
$img = fread($handle , filesize($tmpName));
fclose($handle );
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$img = base64_encode($img);
$sql = "insert into ids_blob values(null,'$fileType','$img','$fileSize', Null, '$fileName');";
mysql_query($sql) or die('SQL Insert Failed!!!'.mysql_error());
echo "Success! You have inserted your picture!";
}
?>
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
*****************************<end index.php>
*****************************<begin images.php>
<?php
include('db_config.php');
$query = "SELECT count(*) as num FROM ids_blob";
$total_pages = mysql_fetch_array(mysql_query($query));
$nrows = $total_pages[num];
//echo "numrows-".$nrows;
echo "<table border='1'><tr align='center' valign='top'>";
for ($i = 1; $i <= $nrows; $i++ ) {
$sql = "select image_id, image_name from ids_blob where image_id ='$i'";
$result = mysql_query($sql) or die('SQL Query Failed!!!'.mysql_error());
$row = mysql_fetch_array($result);
$id = $row['image_id'];
$name = $row['image_name'];
//start new row every 10th picture/icon, using PHP modulus to check for perfect division by 10....
if ($i == (($i-1) % 10 == 0)){
echo "<tr align='center' valign='top'><td width ='60'height= '60'>";
echo $id."<br><img src=\"retrieve_binary_data.php?id=".$id."\">";
echo "</td>";
}else{
echo "<td width ='60'height= '60'>";
echo $id."<br><img src=\"retrieve_binary_data.php?id=".$id."\">";
echo "</td>";
}
}
echo "</tr></table>";
?>
<img src="icon.ico"> <!--- just to prove that an ICON display using a standard html image tag --->
*****************************<end images.php>
*****************************<begin retrieve_binary_data.php>
<?php
//---------------------
// Connect to Database
//---------------------
include('db_config.php');
$id = $_GET['id'];
$sql = "select image, image_type from ids_blob where image_id ='$id'";
$result = mysql_query($sql) or die('Bad query at 12!'.mysql_error());
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
$db_img = $row['image'];
$type = $row['image_type'];
$db_img = base64_decode($db_img); //print_r($db_img );
echo($db_img);
}
imagedestroy($db_img);
?>
*****************************<end retrieve_binary_data.php>
|