if($Image['error'] == 0)
{
//找路径
$query="SELECT path FROM ".$StrClassTblname." WHERE id=$Fatherid";
$result = $DB->sql_query( $query);
$row= $DB->sql_fetchrow($result);
$path = $row['path'];
$name = $Image['name'];//原来文件名
$filename = time().strrchr($Image['name'],".");//新文件名 //先判断数据库中有相同的名字?
$query="SELECT id FROM ".$StrTblname." WHERE path='$path' AND name='$name' AND magazineid=".$IntMagId;
$result = $DB->sql_query( $query);
if(!$DB->sql_fetchrow($result))
{
$query="SELECT magpath,webdir FROM bt_magazine WHERE id=".$IntMagId;
$result = $DB->sql_query( $query);
$row= $DB->sql_fetchrow($result);
$magpath =$row['magpath'];
$webdir = $row['webdir']; //if($needCopyName)
if(CopyFile($Image['tmp_name'], $webdir."/".$magpath."/".$StrDir."/".trim($path)."/".$filename))
{
$query = "INSERT INTO ".$StrTblname." (fatherid,path,name,description,filename,magazineid) VALUES ($Fatherid,'$path','$name','$description','$filename',$IntMagId)";
if (CFG_DBTYPE == "oracle")
{
$query = "INSERT INTO ".$StrTblname." (id,fatherid,path,name,description,filename,magazineid) VALUES (".$StrTblname."_id.NEXTVAL,$Fatherid,'$path','$name','$description','$filename',$IntMagId)";
}
$DB->sql_query($query);
control_sql($query,$IntMagId,3,1); }
}
{
//找路径
$query="SELECT path FROM ".$StrClassTblname." WHERE id=$Fatherid";
$result = $DB->sql_query( $query);
$row= $DB->sql_fetchrow($result);
$path = $row['path'];
$name = $Image['name'];//原来文件名
$filename = time().strrchr($Image['name'],".");//新文件名 //先判断数据库中有相同的名字?
$query="SELECT id FROM ".$StrTblname." WHERE path='$path' AND name='$name' AND magazineid=".$IntMagId;
$result = $DB->sql_query( $query);
if(!$DB->sql_fetchrow($result))
{
$query="SELECT magpath,webdir FROM bt_magazine WHERE id=".$IntMagId;
$result = $DB->sql_query( $query);
$row= $DB->sql_fetchrow($result);
$magpath =$row['magpath'];
$webdir = $row['webdir']; //if($needCopyName)
if(CopyFile($Image['tmp_name'], $webdir."/".$magpath."/".$StrDir."/".trim($path)."/".$filename))
{
$query = "INSERT INTO ".$StrTblname." (fatherid,path,name,description,filename,magazineid) VALUES ($Fatherid,'$path','$name','$description','$filename',$IntMagId)";
if (CFG_DBTYPE == "oracle")
{
$query = "INSERT INTO ".$StrTblname." (id,fatherid,path,name,description,filename,magazineid) VALUES (".$StrTblname."_id.NEXTVAL,$Fatherid,'$path','$name','$description','$filename',$IntMagId)";
}
$DB->sql_query($query);
control_sql($query,$IntMagId,3,1); }
}
解决方案 »
- php获取中文字符乱码
- 本人菜鸟,想问下我下载了一个php网站,php环境也搭建好了,如何运行???
- smarty中unregister_function 函数如何使用
- 请教:页面后退
- 读取文件出错,帮解决!
- 请教怎样发送from邮件,打开邮件是网页
- 在js中,用window.showModalDialog弹出的窗口,如果访问父窗口的值 ,还有,我弹出的窗口中,如何刷新父窗口
- 【高手通道】【5000 分 问题求解 5000 分】【高手通道】
- 当我访问http://127.0.0.1/phpinfo.php 时
- 求指导
- 从mysql取出的文章内容,每段前的两个空格不见了,怎么恢复
- 哪位有用session做的购物车的例子,在线等!!
=============================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件上传</title>
</head>
<body>
<form action="getfile.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="2048000">
文件上传: <input type="file" name="userfile" size=16>
<input type="submit" value="上传">
</form>
</body>
</html>
======================================================
getfile.php
==============================================
<?
$updir='up_files/';
echo $_FILES['userfile']['name']."<br>";
echo $_FILES['userfile']['type']."<br>";
echo $_FILES['userfile']['size']."<br>";
echo $_FILES['userfile']['tmp_name']."<br>";
echo $_FILES['userfile']['error'];If ($userfile != "none") {
echo "userfile:". $_FILES['userfile']['name']."<br>";
echo "userfile_name:". $_FILES['userfile']['tmp_name']." (Size: ".$_FILES['userfile']['size'].")<br>";
move_uploaded_file($_FILES['userfile']['tmp_name'],$updir.$_FILES['userfile']['name']);
echo "上传完成";
} else {
echo "上传失败";
}
?>
===========================================================上传后会显示一些资料,有助你解决问题,请参考。
如何把他们插入到数据库里事图片不一样呢。
表单页面:<input type=file name=userfile>
php程序流程:
1).先判断是否为有效上传文件,if(is_uploaded_file($userfile))
2).如果是,返回true,打开文件,$file=fopen($userfile,"r");
3).读取文件,$filecontents=fread($file,filesize($userfile));
4).转义文件中的特殊字符,$filecontents=addslashes($filecontents);
5).将数据插入数据库,insert into table values($filecontents,......);
这个是我写的。有兴趣的话可以看看。PEARLFOTO 明珠相册(共享版) v1.11b
功能介绍:
1. 使用模板技术PHPLIB
2. 自动生成缩略图清晰度设置
3. 是否开启防盗链功能
4. 长字符串自动截取
5. 支持文字水印,可自定义字体、阴影、颜色、旋转角度等
6. 支持图片水印
7. 可以根据需要设定目录访问密码
8. 统计图片点击次数
9. 批量删除图片
10.发表评论,支持BBCODE
11.支持鼠标滚轮放大&缩小图片.
12.相册打包下载
13.手动生成/更新所有html图片页(共享版不提供)
14.不良信息举报(共享版不提供)
15.图片上传审查功能(共享版不提供)
16.多语言支持(共享版不提供)
17.多页面模板支持(共享版不提供)
18.128位MCRYPT加密
初始管理员:admin
密码:admin888
上面这步是起什么作用呢?
存入
$fd3 = fopen("$upfile3", "r" );$mysqlPicture3 = addslashes(fread($fd3, $PSize3));
insert $mysqlPicture3 到你的数据库中就可以了。
取出时:echo "$row[image3]";记住一定是一张一张的输出。。
在执行getfile.php时提示:
Notice: Undefined variable