例子一大堆,但是照着做都不行。我的客户端是win,服务器端是linux   :(

解决方案 »

  1.   

    我这里有一个文件,你看看
    <?
    session_start();
    require"../config.php";
    require"../check2.php";
    ?>
    <html>
    <head>
    <title>文件上传</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <form action="" method="post" enctype="multipart/form-data" name="form1">
      <table width="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000CC">
        <tr>
          <td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr bgcolor="#F6F6F6"> 
                <td width="181">&nbsp;</td>
                <td width="419">&nbsp;</td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td colspan="2"><div align="center"><strong><font color="#006633">文 
                    件 上 传</font></strong></div></td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td><div align="right"><font color="#003366" size="2">所属类别:</font></div></td>
                <td><select name="lei" size="1">
                    <option>***请选择***</option>
                    <option value="yg">员工照片</option>
                    <option value="open">开料整形系列</option>
                    <option value="hot">热压烫压系列</option>
                    <option value="heigh">高频机系列</option>
                    <option value="gule">胶水涂布系列</option>
                  </select></td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td height="27"><div align="right"><font color="#003366" size="2">文件名称:</font></div></td>
                <td><input type="text" name="name1"></td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td><div align="right"><font color="#003366" size="2">说明内容
                    <input type="hidden" name="cbg" value="clf">
                    :</font></div></td>
                <td><textarea name="intro" cols="50" rows="6"></textarea></td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td height="34"><div align="right"><font color="#003366" size="2">请选择要上传的文件:</font></div></td>
                <td> <input type="hidden" name="PHP_MAX_SIZE" value="1000000"> <input type="file" name="picfile"> 
                </td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td height="46" colspan="2"><div align="center"> 
                    <input type="submit" name="submit" value="上传文件">
                    &nbsp;&nbsp; 
                    <input type="reset" name="Reset" value="全部重置">
                  </div></td>
              </tr>
              <tr bgcolor="#F6F6F6"> 
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    <?
    if($cbg=="clf")
    {
        if($picfile!="")
           {
              $path="image3/";
              @mkdir($path);
              $exten=strchr($picfile_name,".");
              $newpicfile="pic".date("YmdHis").$exten;
      $newpicfiles=$newpicfile;
      $newpic=$path.$newpicfile;
      echo $newpicfile;
              if(copy($picfile,$newpic))
      {
                  echo"图片上载成功<br>";
       }
       else
      {
          echo"图片上载失败!";
      }
              unlink($picfile);
          }
      else
          {
              echo"请选择要上传的图片<meta http-equiv=refresh content=1;url=upload.php>";
          }
    $connect=mysql_connect($host,$root,$pas);
    mysql_select_db($db);
    $result2=mysql_query("select * from $pic");
    $query="insert into $pic(lei,name1,intro,picname) values('$lei','$name1','$intro','$newpicfile')";
    $result=mysql_query($query);echo $result."<br>";
    if($result)
    {
    echo"添加成功";
    }
    else
    {
    echo"添加失败";
    }
    mysql_close($connect);
    }
    ?>
      

  2.   

    <?php 
    if($ima_name!="")
    {
    $extname=substr($ima_name,-3);
            if($extname!="gif"&&$extname!="jpg")  //判断图片格式
                {
                 header("location:test.php?err=图片格式错误!");
                 exit;
                 }
    else
    {
                $utime=time();  
                $pic="../image/".$utime.$ima_name;  //图片上传到的路径+文件名称
                $pic2=$utime.$ima_name; //文件名称
       copy($ima,$pic);
    }

    ?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
    <input name="ima" type="file" id="ima">
    </form>
      

  3.   

    我如果加了  enctype="multipart/form-data"  这句后 $_POST["file"]或$_FILE["file"]["name"]等就都没有值了??
    而我不加的话,在运行到ftp_put()函数时就报错??
      

  4.   

    晕~
    是$_FILES而非$_FILE精华区很多例子,看看嘛
      

  5.   

    我的程序就是照着例子做了,但总是在ftp_put()函数出错???在php.ini中哪项是配置ftp或http上传的谢谢!
      

  6.   

    ftp、http和表单上传根本就不同,怎么能混合使用?该用什么就用什么。
      

  7.   

    我是先试了http方式不行,然后改用ftp方式的,但也不行。问一下,用ftp方式,是不是不用加:  enctype="multipart/form-data"   ?
      

  8.   

    你用的是ftp长传,首先要保证你有ftp服务器,比如server-U。
    php.ini:allow_url_fopen = On
    最好还是用http方式的,用copy函数