文章詳情頁
PHP copy函數使用案例代碼解析
瀏覽:85日期:2022-09-09 09:42:14
copy—拷貝文件
說明
copy(string$source,string$dest[,resource$context] ) :bool
將文件從source拷貝到dest。
如果要移動文件的話,請使用rename()函數。
參數
source
源文件路徑。
dest
目標路徑。如果dest是一個 URL,則如果封裝協議不支持覆蓋已有的文件時拷貝操作會失敗。
Warning
如果目標文件已存在,將會被覆蓋。
context
A valid context resource created withstream_context_create().
返回值
成功時返回TRUE, 或者在失敗時返回FALSE。
更新日志
版本 說明 5.3.0 增加了對 context 的支持。 4.3.0 如果啟用了“fopen wrappers”的話,source和dest都可以是 URL。更多細節見fopen()。
案例
Example #1copy()例子
<?php $file = ’example.txt’; $newfile = ’example.txt.bak’; if (!copy($file, $newfile)) { echo 'failed to copy $file...n'; } ?>
參考
move_uploaded_file()- 將上傳的文件移動到新位置 rename()- 重命名一個文件或目錄 The section of the manual abouthandling file uploads以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
標簽:
PHP
相關文章:
排行榜