问题是将图像存储在数据库中 [英] Problem is storing the image in databse
本文介绍了问题是将图像存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
使用php上传数据库中的图像时遇到问题
请帮帮我.
下面是代码:-
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"]); //insert the values in database $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'')"); /*echo $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(''".$item_location."'',''".$item_type."'',''".$pos."'',''".$item_size."'',''".$item."'',''".$item_heading."'',''".$item_content."'',''".$item_sale_price."'',''".$item_regular_price."'',''".$item_catagory."'',)"); exit();*/ if($sqlin) { $ms="Data Saved"; header("location:manage_item.php?ms=$ms"); } } ob_end_flush(); ?>
< html xmlns =" >
< 头部 >
< 元 =" Content-Type" 内容 =" text/html; charset = utf-8" / < 标题 > 添加项目< /title >
< 样式 =" text/css" <!-
.style1 {
颜色:#FFFFFF;
font-weight:粗体;
}
->
< /style >
< /head >
< 正文 >
< 表单 =" item_form" 操作 add_item.php " 方法 发布" < 表 =" 341" 边框 1" align =" 居中" < tr >
< td =" 32" colspan 2" bordercolor =" #FFFFFF" bgcolor #0000FF" < =" class style1" > ADD ITEM < /div > < /td >
< /tr >
< tr >
< td =" 131" < >
< td =" 194" < 名称 =" 样式 =" >
< 选项 > 首页< /option >
< 选项 > 内部< /option >
< /select > < /td >
< /tr >
< tr >
< td =" 131" < >
< td > < 选择 =" item_catagory" 样式 =" >
< 选项 > 直升机< /option >
< 选项 > Car < /option >
< 选项 > 备件< /option >
< /select > < /td >
< /tr >
< tr >
< td > 选择位置< /td >
< td > < 选择 =" item_position" 样式 =" >
< 选项 > 左< /option >
< 选项 > 右< /option >
< 选项 > 顶部< /option >
< 选项 > 底部< /option >
< /select > < /td >
< /tr >
< tr >
< td > 选择商品尺寸< /td >
< td > < 选择 =" item_size" > ;
< 选项 > 10px < /option >
< 选项 > 12px < /option >
< 选项 > 14px < /option >
< 选项 > 16px < /option >
< 选项 > 18px < /option >
< 选项 > 20px < /option >
< 选项 > 22px < /option >
< 选项 > 14px < /option >
< 选项 > 26px < /option >
< /select > < /td >
< /tr >
< tr >
< td > 上传< /td >
< td > < 输入 =" 文件" 名称 =" 大小 =" / > < /td >
< /tr >
< tr >
< td > 图片< 输入 =" 收音机" 名称 =" 值 =" 图像 >/ > < /td > ;
< td > 视频
< 输入 =" 名称 item_type" 值 =" 视频" / < >
< /tr >
< tr >
< td > 标题< /td >
< td > < 输入 =" 文本" 名称 =" 值 =" / >> ; < /td >
< /tr >
< tr >
< td > 内容< /td >
< td > < 文本区域 =" item_content" cols =" 行 =" > < > /td >
< /tr >
< tr >
< td > 销售价格< /td >
< td > < 输入 =" 文本" 名称 =" 值 =" / >> ; < /td >
< /tr >
< tr >
< td > 常规价格< /td >
< td > < 输入 =" 文本" 名称 =" 值 =" / >> ; < /td >
< /tr >
< tr >
< td > < /td >
< td > < 输入 =" 提交" 名称 =" 值 =" / > < /td > ;
< /tr >
< /table >
< /form >
< /body >
< /html >
问候,
Shiana
解决方案
image =
_FILES [''image''] [''name''];
msg ="; if(isset(
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"]); //insert the values in database $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'')"); /*echo $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(''".$item_location."'',''".$item_type."'',''".$pos."'',''".$item_size."'',''".$item."'',''".$item_heading."'',''".$item_content."'',''".$item_sale_price."'',''".$item_regular_price."'',''".$item_catagory."'',)"); exit();*/ 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">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</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
解决方案
image=
_FILES[''image''][''name''];
msg=""; if(isset(
这篇关于问题是将图像存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文