作者Xp3310 (Nokia)
看板PHP
標題[請益] php 檔名互換
時間Tue Feb 3 00:18:46 2015
如標題
最近做的功能需要檔名互換
我是這樣寫的
rename($target, 'tempName');
rename($ori, $target);
rename('tempName', $ori);
可是結果卻是錯的 檔名並沒有互換掉
請問有可能是什麼原因阿? 謝謝各位
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.161.9.182
※ 文章網址: https://webptt.com/m.aspx?n=bbs/PHP/M.1422893928.A.351.html
1F:→ MOONRAKER: (1)改成tempName 因為/沒有權限 得到寫入錯誤一枚 02/03 00:37
2F:→ MOONRAKER: (2)別提$ori $target因為是短檔名 可能根本找不到 02/03 00:37
3F:→ MOONRAKER: 直接吃file not found錯誤數枚 02/03 00:38
4F:→ MOONRAKER: (3)從頭錯到尾當然不會互換了 02/03 00:38
大大 結果最後是有互換的
只是因為 瀏覽器 image cache 的關係
讓我以為沒有換到 QQ
※ 編輯: Xp3310 (1.161.9.182), 02/03/2015 01:35:14
5F:→ MOONRAKER: cache可以在檔名後面加上 ?x=亂數 來逼他更新。 02/03 09:18
6F:→ MOONRAKER: 另外我還是很好奇你每個參數到底有沒有都full path 02/03 09:19
恩恩 後來的確是用亂數來解決 但覺得這樣解很醜 哈
還有我的那隻檔案是放在根目錄 所以一定會是 full path~
※ 編輯: Xp3310 (36.228.137.95), 02/04/2015 22:30:38
7F:→ MOONRAKER: 醜無所謂 習慣就好 畢竟他合於協定又沒有其他副作用 02/05 00:21