[英]PHP rename() file_exists()
如何使用PHP移動文件?
碼:
if( file_exists($imageLocation) )
echo "file exists on server";
rename($imageLocation, $imageNewLocation);
輸出:
服務器上存在文件警告:重命名(/home/images/file1.jpg,/home/newloc/renamed.jpg)[function.rename]:/home/apps/images/add.php中沒有這樣的文件或目錄81
我不知道從哪里開始。
移動文件時, rename()
只能將它們移動到已存在的文件夾中。 它無法動態創建新的父目錄。
確保/home/newloc
存在。 如果沒有,請使用mkdir()
創建它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.