$data = addslashes(fread(fopen($form_data,"r"),filesize($form_data))); 
建议将上面一句话,分成很多步来调试。
echo $form_data;
echo filesize($form_data); 
echo fopen($form_data,"r");
echo fread(fopen($form_data,"r"),filesize($form_data));
echo addslashes(fread(fopen($form_data,"r"),filesize($form_data))); 
echo $data;

解决方案 »

  1.   

    按照laosan(老三)你的建议的话,那$data这个变量怎么得来?调试后还是行不通啊。我贴出的程序是很完整的程序,希望能在我的程序上作修改,谢谢!
      

  2.   

    <?
    include("db.inc");
    $connection=db_connect();
    /*
    if($s_usrname=="")
    {
      Header("Location: error.php");
       exit;
    }
    */
    //本页面进行新闻添加的操作
    if($submit=="添 加"){
    $picpath = $file_name;
    $dest = $path.$file_name;
    if($file==none)
    {
    $picpath=" ";
    }
    else
    {
    copy($file,$dest);
    }
    $sql="insert into binary_data(time,picpath,id) values('$time','$picpath','$id')";
    $cursor=mysql_query($sql);
    if($cursor)
    {
    $errmessage= "成功添加";
    }
    else
    {
    $errmessage="数据库错误,请稍侯再试";
    }
    }
    ?>
    <form name="form1" method="POST" action="<?echo $php_self;?>"  enctype="multipart/form-data">
      <div align="center">
        <center>
          <table border="0" cellspacing="0" width="100%" cellpadding="0">
          <tr>
          <td width="18%" align="right" height="30" class="unnamed2" valign="middle" bgcolor="#FFFFFF">路径:</td>
          <td width="82%" height="30" bgcolor="#FFFFFF">
          <input type="file" name="file" size="20">
          </td>
          </tr>
          </table>
          </center>
      </div>
      <div align="center">
        <center>
          <p>
            <input type="submit" value="添 加" name="submit" class="unnamed5">
            &nbsp;
            <input type="reset" value="清 除" name="reset" class="unnamed5">
          </p>
        </center>
      </div>
    </form>已经解决了。