-
如何将创建的文档放到指定目录
//html 文件
<body>
<form action="../php/test.php" method="post" enctype="multipart/form-data">
<input type="file" name="pic" id="pic" value="" />
<input type="submit" name="submit" value="提交"/>
</form>
</body>
// php 文件
<?php
if(!empty($_POST['submit'])) {
if(!empty($_FILES['pic']['name'])) {
$type = $_FILES['pic']['type'];
if($type == "image/jpeg" || $type == "image/png") {
// 定义一个变量,存储相对该PHP的相对位置
$path = "../img/";
// path. 将拷贝完成的图片,拼接好指定目录
$result = move_uploaded_file($_FILES['pic']['tmp_name'],$path.$_FILES['pic']['name']);
}
if($result) {
$val = $_FILES['pic']['name'];
// 在创建文件的时候将文件创建到指定位置
$fp = fopen("../txt/test.txt","a+");
fwrite($fp,$val);
fclose($fp);
}
}
}
?>