jamieynonan / file-management
此类可以从URL导入文件,或移动、复制并在服务器上重命名现有文件
1.0.1
2016-06-23 05:28 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-09-16 15:58:40 UTC
README
此库可以从URL导入文件,或在服务器上移动、复制和重命名现有文件。
这个库可以从URL导入文件,或在服务器上移动、复制和重命名现有文件。
此库可以从URL导入文件,或在服务器上移动、复制和重命名现有文件。
示例
use FileManagement\File; $imgLocal = new File(__DIR__ .'/file.jpg'); //file $imgUrl = new File('http://site.com/files/image.png'); //link
验证MIME(可选 - 推荐)
//return bool $imgLocal->validateMime('image/jpeg'); $imgUrl->validateMime('image/png');
保存文件
first set the path to save the file $imgLocal->setPath(__DIR__ . '/files'); $imgUrl->setPath('/path/local/where/save/file'); $imgLocal->save(); $imgUrl->save('new-name'); //save and change name
复制、移动、重命名(仅限于内部文件 - 在服务器上)
//return new instance of File $newImage = $imgLocal->copy('/same/path', 'new-name'); //copy with another name $newImage2 = $newImage->copy('/new/path2'); //copy in another folder with the same name $newImage2->move('/other/path'); //return bool $newImage2->rename('new-name-file'); //return bool