PHP----fcreate(create,delete,copy)
来源:互联网 发布:帝国cms淘宝客模板 编辑:程序博客网 时间:2024/06/07 08:01
<?php header("Content_Type:text/html;charset=utf-8");/*opendir() 打开目录 return: handle/falsereaddir() 读取目录 return: handle/falseis_dir() 判断不否目录 return: handle/falsemkdir() 建立目录 return: true/falsegetcwd() 得到当前目录 return: path/falsechdir() 改变当前目录 return: true/falsermdir() 删除目录 return: true/falserename() 为目录改名 return: true/falsescandir() 文件夹所有内容 return: array/false模式描述ronly read 只读。在文件的开头开始。r+read/write 读/写。在文件的开头开始。wonly write 只写。打开并清空文件的内容;如果文件不存在,则创建新文件。w+read/write 读/写。打开并清空文件的内容;如果文件不存在,则创建新文件。aand to 追加。打开并向文件文件的末端进行写操作,如果文件不存在,则创建新文件。a+read/and to 读/追加。通过向文件末端写内容,来保持文件内容。xonly write 只写。创建新文件。如果文件以存在,则返回 FALSE。x+read/write 读/写。创建新文件。如果文件已存在,则返回 FALSE 和一个错误。注释:如果 fopen() 无法打开指定文件,则返回 0 (false)。*/
$file_path = $_SERVER['DOCUMENT_ROOT']."/wp_php/style/image/";//create null file(file not exist create ,exist no create file)if(touch($file_path."touch1.txt")){echo "<br> create null file:success";}else{echo "<br> create null file:fail";}
//create file(同时往file 里加内容)if(!file_exists($file_path."create1.txt")){$handle = fopen($file_path."create1.txt", "w+");if(fwrite($handle, "create file content")){echo "<br> create file: success";}else{echo "<br> create file: fail";}fclose($handle);}else{echo "<br> create file: exist";}//rename fileif(rename($oldname, $newname)){echo "rename file: success";}else{echo "rename file: fail";}
//Copy fileif(file_exists($file_path."create1.txt")){if(copy($file_path."create1.txt", $file_path."create2.txt")){echo "<br> copy file: success";}else{echo "<br> copy file:fail";}}else{echo "<br> copy file: not exist";}
//chinaese char 中文字符路径乱码处理$file_path = iconv("utf-8", "gb2312", "D:\\新建文件夹\\2.jpg");if(!is_file("D:\\22.jpg")){if(copy($file_path, "D:\\22.jpg")){echo "<br />"."coyp file success";}else{echo "<br />"."coyp file fail";}}else{echo "<br />"."coyp file: exist";}
//Delete fileif(file_exists($file_path."create2.txt")){if(unlink($file_path."create2.txt")){echo "<br> delete file success";}else{echo "<br> delete file fail";}}else{echo "<br> delete file: not exist";}?>
0 0
- PHP----fcreate(create,delete,copy)
- PHP----Folder(create,delete,多级)
- File类 ;File.Create(),File.Delete(), File.Copy(), File.Replace()
- Create, Read, Write, Copy, Move and Delete a Text File using C#
- Create, Read, Write, Copy, Move and Delete a Text File using C# and VB.NET
- 记录一个:Create, Update, Delete and Copy Item Activity in SharePoint 2010 Workflow
- 光棍节...Copy...Delete
- create & delete svn service
- 2.php访问mysql数据库(Create Retrieve Update Delete:增删改查)
- js array json copy delete ...
- Create/Delete list via powershell
- LinkList的create,delete,print
- copy first ,then create your own life!
- Install GraphLab Create --copy from turi
- vim中copy或者delete的技巧
- 路由COPY,DELETE,域名解析,域名服务器小结
- create/edit/delete/startup/shutdown Oracle Instance
- SQL case when,create, delete table
- C++设计模式实现--原型模式
- eclipse下jni初学,调用helloworld.dll,打印字串”Hello world!”
- 游标使用示例
- Hadoop相关备忘
- 服装装饰:门襟设计
- PHP----fcreate(create,delete,copy)
- C++设计模式实现--建造者
- 好滴技术博客汇总
- UVALive 3971 Assemble
- 理解和使用alsa配置-默认静音,必须先用amixer解除主音量和pcm音量的静音
- C语言中的数据类型及其转换详解
- 消息中间件的技术选型心得-RabbitMQ、ActiveMQ和ZeroMQ
- linux下C和shell调用的popen函数
- [Java]读取文件方法大全