說明
bool
copy ( string source, string dest )
將檔案從 source 複製到 dest。若果成功則返回 TRUE,失敗則返回 FALSE。
例子 1. copy() 例子
<?php $file = 'example.txt'; $newfile = 'example.txt.bak';
if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?>
|
|
若果要搬移檔案的話,請使用 rename() 函數。
注:
從 PHP 4.3.0 開始,若果啟用了「fopen wrappers」的話,source 和
dest 都可以是 URL。更多細節見 fopen()。若果
dest 是一個 URL,則若果封裝協定不支援覆蓋已有的檔案時複製動作會失敗。
Windows 相容:
若果複製一個零位元組的檔案,copy()
將返回 FALSE ,但檔案也會被正確複製。
參見 move_uploaded_file(),rename()
和手冊中的檔案上傳處理一章。