Hi All
I am facing a problem while uploading the images in database using php
Please help me out.
Below is code:-
ob_start();
$image=$_FILES['image']['name'];
$msg="";
if(isset($_POST['submit']))
{
include("dbconnect.php");
$image=$_FILES['image']['name'];
$item_heading=$_POST['item_heading'];
$item_size=$_POST['item_size'];
$item_content=$_POST['item_content'];
$item_type=$_POST['item_type'];
$item_sale_price=$_POST['item_sale_price'];
$item_regular_price=$_POST['item_regular_price'];
$item_catagory=$_POST['item_catagory'];
$loc=$_POST['item_location'];
$pos=$_POST['item_position'];
move_uploaded_file($_FILES["image"]["tmp_name"],"/hi/".$_FILES["image"]["name"]);
$sqlin=mysql_query("insert into add_item(item_page,item_type,item_pos,item_size,item,item_heading,item_content, item_sale_price,item_regular_price,item_catagory) values('$loc','$item_type','$pos','$item_size','$image','$item_heading','$item_content','$item_sale_price','$item_regular_price','$item_catagory')");
if($sqlin)
{
$ms="Data Saved";
header("location:manage_item.php?ms=$ms");
}
}
ob_end_flush();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Item</title>
<style type="text/css">
</style>
</head>
<body>
<form name="item_form" action="add_item.php" method="post">
<table width="341" border="1" align="center">
<tr>
<td height="32" colspan="2" bordercolor="#FFFFFF" bgcolor="#0000FF"><div align="center" class="style1">ADD ITEM</div></td>
</tr>
<tr>
<td width="131">Choose Page</td>
<td width="194"><select name="item_location" style="width:100px;">
<option>Home</option>
<option>Internal</option>
</select> </td>
</tr>
<tr>
<td width="131">Select Catagory</td>
<td><select name="item_catagory" style="width:100px;">
<option>Helicopter</option>
<option>Car</option>
<option>Spare Part</option>
</select></td>
</tr>
<tr>
<td>Select Position</td>
<td><select name="item_position" style="width:100px;">
<option>Left</option>
<option>Right</option>
<option>Top</option>
<option>Bottom</option>
</select> </td>
</tr>
<tr>
<td>Select Item Size</td>
<td><select name="item_size">
<option>10px</option>
<option>12px</option>
<option>14px</option>
<option>16px</option>
<option>18px</option>
<option>20px</option>
<option>22px</option>
<option>14px</option>
<option>26px</option>
</select> </td>
</tr>
<tr>
<td>Upload</td>
<td> <input type="file" name="image" size="20" /></td>
</tr>
<tr>
<td>Image <input type="radio" name="item_type" value="image" /></td>
<td>Video
<input type="radio" name="item_type" value="video" /></td>
</tr>
<tr>
<td>Heading</td>
<td><input type="text" name="item_heading" value="" /></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name="item_content" cols="17" rows="3"></textarea></td>
</tr>
<tr>
<td>Sale Price</td>
<td><input type="text" name="item_sale_price" value="" /></td>
</tr>
<tr>
<td>Regular Price</td>
<td><input type="text" name="item_regular_price" value="" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="ADD ITEM" /></td>
</tr>
</table>
</form>
</body>
</html>
Regards,
Shiana