请问如何把用户上传的文件(所有)都保存在sql里面? 有这个必要吗??用<input type="file" name="test">不行吗?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 和保存图片差不多吧,改吧这是不知什么时期的代码段//PHP代码if($create) {//生成文件$connect=@mysql_connect('localhost','***','****');$dbname='****';$select=mysql_select_db($dbname,$connect); $query="select image from imagetable where 1=1"; //$query="DELETE FROM imagetable"; $result=mysql_query($query); $all=0; while($row=mysql_fetch_object($result)) { $all=$all+1; echo $row->image; } echo "<div>"; echo $all; echo "</div>"; }if($file!="") { //存储图片数据//读入上传的图片数据 $connect=@mysql_connect('localhost','***','***'); $dbname='***'; $select=mysql_select_db($dbname,$connect); $imagecontent=addslashes(fread(fopen($file,"r"),filesize($file))); $query="insert into imagetable(id,image,filename,filetype) values ('','$imagecontent','$file_name','$file_type')"; if($file!="none" and $file!="") { mysql_query($query); } }?><form name="form1" method="post" action="" enctype="multipart/form-data"> <input type="file" name="file"><INPUT TYPE="hidden" name=create value=1> <input type="submit" name="confirm" value="Submit"></form> http://expert.csdn.net/Expert/topic/1344/1344404.xml?temp=.3839075 直接读文件写文件到数据库吧不过为什么要addslash呢? 什么啊。"和'也会被转换的啊。再slip不就可以恢复了嘛。 用silp??这么用的 ??呆会我另外开个问题来讨论这个。。 还是用<input type="file" name="test">简单! if($create) {//生成文件$connect=@mysql_connect('localhost','***','****');$dbname='****';$select=mysql_select_db($dbname,$connect); $query="select image from imagetable where 1=1"; //$query="DELETE FROM imagetable"; $result=mysql_query($query); $all=0; while($row=mysql_fetch_object($result)) { $all=$all+1; echo $row->image; } echo "<div>"; echo $all; echo "</div>"; }这个什么意思? php数组的输出顺序问题,在线等。 ajax小疑问 PHP中如何连接多个数据库,同时操作两个以上的连接对象 eclipse环境搭建(PHP单步跟踪) PHP连接远程MYSQL数据库出错!高手来指教下!急急急急急急~~~~~~ 我这样的在北京能拿多少米 提取二维数组中指定key的元素 请解释一下这些代码的意思 不用xmlhttp实现的了吗? explode 函数为何不可分解中间为空格的字符串? 谁能讲一下$HTTP_SERVER_VARS数组的各个变量 PHP如何接收由checkbox提交来的数据
这是不知什么时期的代码段
//PHP代码
if($create) {
//生成文件
$connect=@mysql_connect('localhost','***','****');
$dbname='****';
$select=mysql_select_db($dbname,$connect);
$query="select image from imagetable where 1=1";
//$query="DELETE FROM imagetable";
$result=mysql_query($query);
$all=0;
while($row=mysql_fetch_object($result))
{ $all=$all+1;
echo $row->image;
}
echo "<div>";
echo $all;
echo "</div>";
}if($file!="") {
//存储图片数据
//读入上传的图片数据
$connect=@mysql_connect('localhost','***','***');
$dbname='***';
$select=mysql_select_db($dbname,$connect);
$imagecontent=addslashes(fread(fopen($file,"r"),filesize($file)));
$query="insert into imagetable(id,image,filename,filetype) values ('','$imagecontent','$file_name','$file_type')";
if($file!="none" and $file!="") {
mysql_query($query);
}
}
?>
<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="file"><INPUT TYPE="hidden" name=create value=1>
<input type="submit" name="confirm" value="Submit">
</form>
不过为什么要addslash呢?
再slip不就可以恢复了嘛。
这么用的 ??呆会我另外开个问题来讨论这个。。
<input type="file" name="test">
简单!
//生成文件
$connect=@mysql_connect('localhost','***','****');
$dbname='****';
$select=mysql_select_db($dbname,$connect);
$query="select image from imagetable where 1=1";
//$query="DELETE FROM imagetable";
$result=mysql_query($query);
$all=0;
while($row=mysql_fetch_object($result))
{ $all=$all+1;
echo $row->image;
}
echo "<div>";
echo $all;
echo "</div>";
}
这个什么意思?