求帮忙解决个图片上传的问题?
<?php
include 'config.php';
?>
<Script language="javascript">
function Clicked()
{
var obj;
obj=document.docForm.txtTitle.value;
if (obj==""||obj==null)
{
alert("标题是必填字段!")
return false;
}
obj=document.docForm.txtContent.value;
if (obj==""||obj==null)
{
alert("内容是必填字段!")
return false;
}
if (obj==""||obj==null)
{
alert("对不起!你还没选择图片。")
return false;
document.docForm.UpPic.focus();
}
return true;
}
function Submited()
{
if (Clicked()==true)
{
document.docForm.submit();
}else{
return false;
}
}
</Script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><?=$WebName;?></title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>
<body>
<div align="center">
<form name="docForm" id="docForm" action="SubFileWrite.php" method="post" enctype="multipart/form-data">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%" align="Right">标题:</td>
<td width="70%" align="Left"><input name="txtTitle" type="text" id="txtTitle" size="40" />
<font color="red">*</font></td>
</tr>
<tr>
<td width="30%" align="Right">图片:</td>
<td align="Left">
<INPUT NAME="txtPic" TYPE="File" id="txtPic">
<input name="UpFile" type="button" id="UpFile" value="上传" /></td>
</tr>
<tr>
<td width="30%" align="Right">图片链接:</td>
<td align="Left"><input name="txtPicUrl" type="text" id="txtPicUrl" size="35" />
<input name="Add" type="button" id="Add" value="添加" /></td>
</tr>
<tr valign="top">
<td width="30%" align="Right">内容:</td>
<td align="Left">
<textarea name="txtContent" id="txtContent" cols="40" rows="10"></textarea>
<font color="Red">*</font> </td>
</tr>
<tr>
<td align="Right"><input name="Submit" type="button" id="Submit" value="提交" OnClick="JavaScript:Submited()" /></td>
<td align="Left"> <input name="Cancel" type="reset" id="Cancel" value="消除" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>
//以上是FileWrite.php源码
<?php
require ('ConnectionDatabase.php');
$db->connect();
//echo "<pre>";print_r($_POST);echo "</pre>";
$query="insert into news_issues (newsTitle,newsContent,newsPic,newsPicUrl,newsCreateDate) values (\"".$_POST['txtTitle']."\",\"".$_POST['txtContent']."\",\"".$_POST['txtPic']."\",\"".$_POST['txtPicUrl']."\",\"".date("Y-m-d H:i:s")."\")";
$db->query($query);
$db->db_close();
echo"<Script Language='JavaScript'>alert('数据添加成功!');location.href='FileWrite.php'</Script>";
?>
//以上是SubFileWrite.php源码
实在搞不懂怎样去实现图片上传功能,求各位能否抽个时间帮忙解决一下
问题点数:100、回复次数:3Top
1 楼anteaus()回复于 2005-11-02 12:39:12 得分 0
自己顶!!!!Top
2 楼hzqghost(Ita)回复于 2005-11-05 00:13:33 得分 0
copy($txtPic,"./文件名")Top
3 楼bflovesnow()回复于 2005-11-05 11:44:07 得分 0
精华区找,N 多!!Top




