php 如何对上传文件的文件名进行重命名
2个回答
2012-04-03 · 知道合伙人软件行家
关注
展开全部
<html>
<body>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="test.php">
上传图片
<input name="tupian" type="file" id="tupian" />
<input type="submit" name="button" id="button" value="上传" />
</form>
<?php
if (isset($_FILES['tupian'])) {
// echo '<pre>';
// print_r($_FILES["tupian"]);
// echo '</pre>';
if ($_FILES["tupian"]['error'] == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["tupian"]["tmp_name"];
$name = $_FILES["tupian"]["name"];
move_uploaded_file($tmp_name, "$name");//在这里进行文件改名
}
echo '<img src="' . $name . '" />';
}
?>
</body>
</html>
<body>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="test.php">
上传图片
<input name="tupian" type="file" id="tupian" />
<input type="submit" name="button" id="button" value="上传" />
</form>
<?php
if (isset($_FILES['tupian'])) {
// echo '<pre>';
// print_r($_FILES["tupian"]);
// echo '</pre>';
if ($_FILES["tupian"]['error'] == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["tupian"]["tmp_name"];
$name = $_FILES["tupian"]["name"];
move_uploaded_file($tmp_name, "$name");//在这里进行文件改名
}
echo '<img src="' . $name . '" />';
}
?>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询