<?php  if(!empty($upload))  {   if(empty($uploadfile))   {    echo $uploadfile;    echo "<script language='javascript'>alert('您还没选择图片呢!怎么上传啊?^_^'); location.href='img.php'</script>";   }   else   {    if($uploadfile_size>102400)    {     echo "<script language='javascript'>alert('您的图片太大,请选择适当的图片!'); location.href='img.php'</script>";     exit;    }    if($uploadfile_type!="image/gif" and $uploadfile_type!="image/pjpeg" and $uploadfile_type!="image/png")    {     echo "<script language='javascript'>alert('请选择gif或jpg或png图片类型!'); location.href='img.php'</script>";     exit;    }    $upfile_path="updates/";    $time=time();    $photo=$time.$uploadfile_name;    $picturename=$upfile_path.$photo;    if(!file_exists($picturename))    {     if(!copy($uploadfile,$picturename))     {      echo "服务器忙,图片上传失败!";      exit;     }     echo "<script language='javascript'>alert('图片上传成功!')</script>";     $upload="";     echo "<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF?picturename=".$picturename."&name=".$photo."\">";    }    else    {     echo "服务器忙,图片上传失败!";     exit;    }   }  }?><html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>超级链接</title><script language="JavaScript"><!--function OkButton(){  if(document.form1.url.value!="")  {   var a = document.getElementsByName("R1");   if(a[0].checked)tmp="[limg]"+document.form1.url.value+"[/limg]";   if(a[1].checked)tmp="[cimg]"+document.form1.url.value+"[/cimg]";   if(a[2].checked)tmp="[rimg]"+document.form1.url.value+"[/rimg]";   window.opener.document.form1.news_content.value+=" "+tmp;   window.opener.document.form1.news_media.value+=" "+"<?=$name?>";   window.close();  }}//--></script></head><body topmargin="0" leftmargin="0" onkeydown="if(event.keyCode==13)OkButton()">  <form method="post" enctype="multipart/form-data" name="form1">    <table cellpadding="0" align="center" cellspacing="0" width="347" height="175" style="font-family: Arial; font-size: 10pt; border-collapse:collapse" bordercolor="#111111">      <tr>      <td height="36" colspan="2">      <p style="margin-left: 4"><font color="#800000">图片链接信息</font></td>    </tr>    <tr>        <td width="78" height="32">          <p align="center">本地图片:</td>        <td width="267" height="32"><input type="file" name="uploadfile" size="12">          <input type="submit" name="upload" <?php if($picturename)echo "disabled" ?> VALUE="上传">          <font color="#FF0000">(<100K)</font> </td>    </tr>    <tr>        <td width="78" height="32">          <p align="center">图片链接:</td>        <td width="267" height="32">          <input type="text" name="url" value="<? if($picturename)echo $picturename; else echo "http://" ?>" size="34"></td>    </tr>    <tr>        <td width="78" height="32">          <p align="center">对齐方式:</td>        <td width="267" height="32">          <input type="radio" value="left" checked name="R1">左对齐       <input type="radio" value="center" name="R1">居中       <input type="radio" value="right" name="R1">右对齐</td>    </tr>    <tr>        <td height="26" colspan="2" align="center"><input type="button" value=" 确 定 " onclick="javascript:OkButton()" name="B1">        <input type="button" value=" 取 消 " onclick="window.close()" name="B2"></td>    </tr>  </table> </form></body></html>

解决方案 »

  1.   

    <?php 
    $file=$_FILES[filename];
    $filename_up=$_POST[dirname2]."/".$file[name];
    //print_r($file);
    //print("$_POST[dirname2]");
    //echo("$file[size]文件超过1M字节");
    if($file[name]=="")
    echo("请选择文件");
    elseif($file[size]>5000000)
    echo("文件超过5M字节");
    elseif(file_exists($filename_up))
    echo("文件已经存在! 请修改或换文件夹".$filename_up);/**/
    else
    {if(move_uploaded_file($file[tmp_name],$_POST[dirname2]."/".$file[name]))
    echo "文件上传成功";
    else
    echo "文件上传失败";}
    ?>
    ////////////// 以上是我简单写的,没有对文件类型进行过滤
      

  2.   

    <?
    if(isset($photoname)){
            $pt=split('/',$photopath_type);
            if($pt[0]!='image'){
                    echo"<script>alert('对不起,只能上传图片文件'); </script>";
            }
            else{
                    $filename=date('YmdHis').'.'.$pt[1];
                    copy($photopath,"upphoto/".$filename);
                    echo"<script>alert('上传成功,您可以继续上传'); </script>";
    echo"<meta http-equiv=\"refresh\" content=\"0;URL=upimg.php\">";
            }
    }
    ?>
    <SCRIPT language="JavaScript">
    <!--
    function validformlogin(){ //by [email protected]
            var loginform=document.imgup
            if (loginform.photoname.value=="") {
                    alert('对不起,图片名不可为空!');
                    loginform.photoname.focus();
                    return false;
            }else if (loginform.photopath.value=="") {
                    alert('对不起,请选择图片!');
                    loginform.photopath.focus();
                    return false;
            }else{
                    return true;
            }
    }
    //-->
    </SCRIPT>
          
    <p align="left"> <br />
     </p>
          <form method="POST" action="" name="imgup" enctype="multipart/form-data" onsubmit="return validformlogin();">
            <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="60%" id="AutoNumber1">
              <tbody>
              <tr>
                <td width="20%" height="25">图片名称:</td>
                <td width="80%" height="25" bgcolor="#F5F5F5">
                <input type="text" name="photoname" size="25" class="redinput" /></td>
              </tr>
              <tr>
                <td width="20%" height="25" bgcolor="#F5F5F5">选择图片:</td>
                <td width="80%" height="25">
                <input type="file" name="photopath" size="25" class="redinput" /></td>
              </tr>
              <tr>
                <td width="28%" height="25">
                <p align="right"> </p></td>
                <td width="72%" height="25">
                <p align="right"> <input type="submit" value=" 提 交 " name="B1" class="button" />&#160;
                <input type="reset" value=" 重 置 " name="B2" class="button" /></p></td>
              </tr>
            </tbody>
            </table>
          </form>
        </TD>
      

  3.   

    $ima_name=$_FILES['ima']['name'];
     if($ima_name!="")
          {
            $extname=substr($ima_name,-3);
    if($extname!="gif"&&$extname!="jpg")
                {
             echo "<script language=javascript>alert('表名称已经更改,但上传图片后缀只能是gif 或 jpg!请重新上传图片文件!');";
             echo "this.location.href='tab_modi.php';</script>";
             exit;
                 }
        else
            {
                $utime=time();
                  $pic="image/".$utime.$ima_name;
       $pic2=$utime.$ima_name;
               copy($_FILES['ima']['tmp_name'],$pic);
                   
       $query_image="select * from ".$new_name;
       $result_image=mysql_query($query_image);
               $num_results_image = mysql_num_rows($result_image);
       
        if ($num_results_image >0)
      {
       $updatesql= "update ".$new_name." set image_name='".$pic2."' where tablename like  '%".$new_name."%'";
       mysql_query($updatesql);
      }
    else
      {
    $insertsql = " insert into  ".$new_name." (image_name) values ('".$pic2."')";
        $Result_image = mysql_query($insertsql);
          }
            }  
       }
      

  4.   

    不用这么麻烦..我给你 $downfile="../downfile/".$upfile_name;
     copy($upfile,"../downfile/$upfile_name");
    downfile这个目录的属性在FTP设一下就可以了...
    不行EMAIL TO ME  [email protected]
      

  5.   

    代码我也下载了好几个,都不行,我怀疑有什么其它的错误因素。不可能每一个都不行呀。
    我记得他们都叫我文件夹属性设为777,可是我是windows2000系统,那么我2000要设什么吗?大家快来帮我呀。
      

  6.   

    windows2000系统不用设定,777是LINUX下的事情,
      

  7.   

    为什么,我用同样的方法不能上传.swf的FLASH文件!?