<form enctype="multipart/form-data" action="test.php" method="POST"> 
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form><?phpecho $_FILES['userfile']['name'];?>

解决方案 »

  1.   

    http://www.eaoo.com/design/list.asp?classid=2&Nclassid=9
      

  2.   

    给我个mail
    我发到你信箱里
      

  3.   

    to Cain(一苇渡江) 
     
    不是要上传文件的文件名,并把他保存到数据库吗?
    <form enctype="multipart/form-data" action="test.php" method="POST"> 
    <input type="hidden" name="MAX_FILE_SIZE" value="30000">
    Send this file: <input name="userfile" type="file">
    <input type="submit" value="Send File">
    </form><?phpecho $_FILES['userfile']['name'];
    //把 $_FILES['userfile']['name']的值存放数据库相应字段即可?>
      

  4.   

    echo $_FILES['userfile']['name'];
      

  5.   


    <?phpecho $_FILES['userfile']['name'];?>
      

  6.   

    <form action="post" name="form1" method="post">
    <input type="file" name="image"><input type="submit" name="Submit" value="上传">
    </form><? if($Submit<>"") {  //这里用了一个自定义的图片上传的类
         $imageupload=new uploadimage();
         $imageupload->setname($image_name);
         $imageupload->setoldpath($image);
         $imageupload->setpath($saveimagedir);
         $imageupload->setwidth($image_width);
         $imageupload->setheight($image_height);
         $imageupload->setsize($image_size);
         $imageupload->setimagetype("news");
         if (!($imagename=$imageupload->upload())) errormsg("图片上传 失败!","提示信息");
         else $imagename=$oldimage;
    $sql="insert into 表名 存图片的字段名 value $imagename";
    if (($errorinfo=mysql_query($sql))==true)                   //insenews()为插入新资料记录
           showmsg("资料添加成功!","提示信息","news.php");
    else   showmsg("资料添加失败!","提示信息","news.php");}//下面是图片上传的类
      

  7.   

    class uploadimage  //图片上传类
    {
    var $name;
    var $oldpath;
    var $width;
    var $hieight;
    var $size;
    var $path="..//infoimages//";
    var $maxsize=1024000;
    var $maxwidth=800;
    var $maxheight=600;
    var $imagetype;function setimagetype($type)
    {
    $this->imagetype=$type;
    } function setname($name)
    {
    $this->name=$name;
    }function setoldpath($oldpath)
    {
    $this->oldpath=$oldpath;
    }function setpath($path)
    {
    $this->path=$path;
    }function setwidth($width)
    {
    $this->width=$width;
    }function setheight($height)
    {
    $this->height=$height;
    }function setsize($size)
    {
    $this->size=$size;
    }function setmaxsize($maxsize)
    {
    $this->maxsize=$maxsize;
    }function setmaxwidth($maxwidth)
    {
    $this->maxwidth=$maxwidth;
    }function setmaxheight($maxheight)
    {
    $this->maxheight=$maxheight;
    }function upload()
    {

    if ($this->name!="")
    { if((getfiletype($this->name)!="gif" or getfiletype($this->name)!="GIF"  or 
    getfiletype($this->name)!="jpg" or getfiletype($this->name)!="JPG") or
    $this->size>=$this->maxsize or $this->width>=$this->maxwidth or $this->height>=$this->maxheight)
    {
    $imageuploadname=$this->imagetype.date("YndHis").".".getfiletype($this->name);
    if (!@copy($this->oldpath,"$this->path$imageuploadname"))
     return false;
    else return $imageuploadname;
    }
    return false;
    }
    }
    }function showmsg($msg,$title,$url) {
        if ($url == "") {
            $url = "history.back(-1)";
            print "<HTML><META HTTP-EQUIV=\'CONTERN-TYPE\' CONTENT=\'TEXT/HTML;CHARSET=GB2312\'>\n";
            print "<title>$title</title><body>\n";
            print "<SCRIPT>\n";
            print "alert(\"$msg\");\n";
            //print "this.location=$url;";
            print "redirect($url);\n";
            print "</SCRIPT></body></html>";
        }
        else {
            $url = "\"$url\"";
            print "<HTML><META HTTP-EQUIV=\'CONTERN-TYPE\' CONTENT=\'TEXT/HTML;CHARSET=GB2312\'>\n";
            print "<title>$title</title><body>\n";
            print "<SCRIPT>\n";
            print "alert(\"$msg\");\n";
            print "window.location = $url;";
            print "</SCRIPT></body></html>";
        }
                   
        exit();
    }