我的一個form表單上傳文件,可以用echo 上傳的路徑,$_FILES['userfile']['name'] 得到任何的值。菜虫,请大家指点。

解决方案 »

  1.   

    你想问什么?
    form中加一个type是file的input就可以了.input的名字叫userfile
      

  2.   

    我是在  form中加一个type是file的input,但是我在action的页面中用$_FILES['userfile']['name']什么都得不到。但是可以echo $_POST[uploadfile]显示出路劲;uploadfile是form中的file input的名字
      

  3.   

    就是在action的 页面中  echo $_FILES['userfile']['name'];什么都出不来。
      

  4.   

    <form action="" enctype="multipart/form-data"  method="post" >form表单的enctype写了么?
      

  5.   

    加了,<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <body>
    <?
    /*if(!is_numeric($_POST[etprice]))
    {
    echo("<script> alert('市場價一定要是數字!' ); history.back();</script>");
    }
    if(!is_numeric($_POST[memberprice]))
    {
    echo("<script>  alert('會員價只能是數字!');history.back();</script>");
    }
    $gname = $_POST[gname];*/
    $year = $_POST[year];
    $month = $_POST[month];
    $date = $_POST[date];
        $etprice = $_POST[etprice];
    $memberprice = $_POST[memberprice];
    $gtype = $_POST[typename];
    $cate =  $_POST[cate];
    $brand = $_POST[brand];
    $goodstype = $_POST[goodstype];
    $recomend =  $_POST[recomend];
    $resum =  $_POST[resum];
    $uploadfile = $_POST[uploadfile];
        echo($uploadfile);
    echo($_FILES['userfile']['name'] ); ?>
    </body>
    </html>
      

  6.   

    echo($uploadfile);
    有值,但是  echo($_FILES['userfile']['name'] );
    没有值。奇怪。
      

  7.   

    echo($_FILES['userfile']['tmp_name']);
      

  8.   

    加个print_r($_FILES);看看结果,如果是空的就像4L说的看看你的enctype="multipart/form-data" 写了没