PHP-操作文件和目录
2019-02-21
本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。
声明: 本博客欢迎转发,但请保留原作者信息!
github地址:atanx
新浪微博:@蜀山掌门V
QQ:365039667
博客地址:江斌的博客
内容仅供学习参考,如有不当引用,请告知博主。
[toc]
[toc]
上传文件
function upload_image()
{
$tmp = $_FILES['file']['tmp_name'];
$name = $_FILES['file']['name'];
$image_path = $_POST['image_path'];
//die($name);
if(move_uploaded_file($tmp,$image_path)){
echo "上传成功";
}else{
echo "上传失败";
}
}
function upload_chatroom_image()
{
$tmp = $_FILES['file']['tmp_name'];
$name = $_FILES['file']['name'];
$image_path = $_POST['image_path'];
$folder = $_POST['image_folder'];
if(!is_dir($folder)){
mkdir($folder);
}
if(move_uploaded_file($tmp,$image_path)){
echo "上传成功";
}else{
echo "上传失败";
}
}
创建目录
$folder = $_POST['image_folder'];
if(!is_dir($folder)){
mkdir($folder);
}