表单enctype="multipart/form-data"发送问题
上传图片的时候表单有enctype="multipart/form-data"方式 但是这个种方式就获取不到text文本的值,求指点
a.html
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><form action="b.php" method="post" enctype="multipart/form-data" id="ces"> 上传:<input type="file" name="filename" /> <input type="submit" value="上传" name="btn"/> <input type="reset" value="取消" name="btn1"/> <input name="" id="test" type="text" /> </form>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><?php
$path="../user_pic/2/"; //上传路径
$c=$_POST['test'];
echo $c;
//echo $_FILES["filename"]["type"];
$file2="a.jpg";
if(!file_exists($path))
{
//检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir("$path", 0700);
}//END IF
//允许上传的文件格式
//if(file_exists($path.$file2))
//{
// $a=$path.$file2;
// if(unlink("$a"))
// {
// echo "aaa";
// }
//
//}
//$tp = array("image/gif","image/pjpeg","image/png","image/jpg");
////检查上传文件是否在允许上传的类型
//if(!in_array($_FILES["filename"]["type"],$tp))
//{
//echo "格式不对";
//exit;
//}//END IF
if($_FILES["filename"]["name"])
{
$file1=$_FILES["filename"]["name"];
echo "aaa";
//$file2 = $path.time().$file1;
//修改上传完毕的文件名
}//END IF
$result=move_uploaded_file($_FILES["filename"]["tmp_name"],$path.$file2);
//特别注意这里传递给move_uploaded_file的第一个参数为上传到服务器上的临时文件
if($result)
{
//echo "上传成功!".$file2;
echo "<script language='javascript'>";
echo "alert(\"上传成功!\");";
}//END IF
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号