PHP移动文件或者文件夹
看到很多人都是用,copy,unlink来实现文件的移动,对于大文件,可能会消耗很长时间,
但是有个更加方便的方式,就是使用php的rename.
有几种情况:
1.对于文件,rename可以在不同盘符之间移动.
2.对于空文件夹,rename也可以在不同盘符之间移动.但是目标文件夹的父目录必须存在.
3.对于非空文件夹,只能在同一盘符下移动.
不过,1和3,应该差不多能够对付所有的应用情况了.
rename("D:/logs/write/theme/history","F:/logs/write/theme/history");
?>
我测试过,对于一个40M的文件,copy+unlink方式需要7.6249899864197秒
而rename方式,只需要0.024738788604736,快300倍.
因此,谨慎使用copy+unlink方式.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Where to find the Crane Control Keycard in Atomfall
1 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1359
52

