请问用PHP写上传的那句涉及服务器的地址,要怎么解决? $uploadfile存在于系统的临时目录中。应该是在/tmp下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是我联系的时候上传图片的源代码,validate.php是连接数据库的包含程序<?php require_once('validate.php'); ?><?phpif(isset($_POST['work'])){ $id = $_POST['id']; $uploaddir = "images/" ; $uploadfile = $uploaddir . date("YmdHis_") . $id . strrchr($_FILES['file']['name'],"."); print "<pre>"; //echo $uploadfile . "<br>" . $id; if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { //print "File is valid, and was successfully uploaded. Here's some more debugging info:\n"; //print_r($_FILES); } else { //print "Possible file upload attack! Here's some debugging info:\n"; print_r($_FILES); } print "</pre>"; //echo $uploadfile; if($_FILES['file']['name']){ $SQL = "UPDATE `pro_ins` SET pic = '".$uploadfile."' , date = '".date("yynj")."' WHERE id = '".$id."' LIMIT 1"; mysql_query($SQL, $link) or die(mysql_error()); }}else{ $id = $_GET['id'];}$SQL = "select * from pro_ins where id='".$id."'";$Rs_pro = mysql_query($SQL, $link) or die(mysql_error());$Rs_row = mysql_fetch_assoc($Rs_pro);?><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><link href="main.css" rel="stylesheet" type="text/css"></head><body><center> <?php if(strlen($Rs_row['pic'])>5){?> <a href="<?php echo $Rs_row['pic'];?>" target="_blank"> <img src="<?php echo $Rs_row['pic'];?>" width="250" height="200" title="单击放大"></a> <?php }else{?> 此产品无可察看图片,请上传图片。 <?php }?> <br> <span class="txt">单击<font color="#FF0000">浏览</font>选择要上传的图片文件,单击<font color="#FF0000">上传</font><?php if($Rs_row['pic'])echo "覆盖";else echo "添加";?>图片。</span> <form name="form1" enctype="multipart/form-data" method="post" action="up.php"> <input name="file" type="file" size="30" maxlength="1024"> <input type="hidden" name="id" value="<?php echo $id;?>"> <input type="hidden" name="work" value="up"> <input type="submit" name="Submit" value="上传"></form></center></body></html> 求类似于discuz或者csdn的内容编辑器,就是对内容进行加粗这些,我要写一个简单的发帖功能 php和mysql5.5的整合 总贴数和今日发贴数如何即时更新? foreach取值问题 有甚麽感觉? php根据条件排除 静态化问题 一个iis可否开多个泛解析? 怎么会出现这种参数错误? 求助!为什么连上MYSQL数据库连不上表格 document.getElementById("Material[index]");里面有变量为什么就不行? 最后确认一下,不需要身份验证的的SMTP服务器就能通过mail()发邮件??
<?php require_once('validate.php'); ?>
<?php
if(isset($_POST['work'])){
$id = $_POST['id'];
$uploaddir = "images/" ;
$uploadfile = $uploaddir . date("YmdHis_") . $id . strrchr($_FILES['file']['name'],".");
print "<pre>";
//echo $uploadfile . "<br>" . $id;
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
//print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
//print_r($_FILES);
} else {
//print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
//echo $uploadfile;
if($_FILES['file']['name']){
$SQL = "UPDATE `pro_ins` SET
pic = '".$uploadfile."'
, date = '".date("yynj")."'
WHERE id = '".$id."' LIMIT 1";
mysql_query($SQL, $link) or die(mysql_error());
}
}else{
$id = $_GET['id'];
}$SQL = "select * from pro_ins where id='".$id."'";
$Rs_pro = mysql_query($SQL, $link) or die(mysql_error());
$Rs_row = mysql_fetch_assoc($Rs_pro);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<center>
<?php if(strlen($Rs_row['pic'])>5){?>
<a href="<?php echo $Rs_row['pic'];?>" target="_blank">
<img src="<?php echo $Rs_row['pic'];?>" width="250" height="200" title="单击放大"></a>
<?php }else{?>
此产品无可察看图片,请上传图片。
<?php }?> <br>
<span class="txt">单击<font color="#FF0000">浏览</font>选择要上传的图片文件,单击<font color="#FF0000">上传</font><?php if($Rs_row['pic'])echo "覆盖";else echo "添加";?>图片。</span>
<form name="form1" enctype="multipart/form-data" method="post" action="up.php">
<input name="file" type="file" size="30" maxlength="1024">
<input type="hidden" name="id" value="<?php echo $id;?>">
<input type="hidden" name="work" value="up">
<input type="submit" name="Submit" value="上传">
</form>
</center>
</body>
</html>