$uploadfile存在于系统的临时目录中。
应该是在/tmp下

解决方案 »

  1.   

    下面是我联系的时候上传图片的源代码,validate.php是连接数据库的包含程序
    <?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>