![]() |
Checking directory listing for unique filename - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Checking directory listing for unique filename (/showthread.php?tid=53222) |
Checking directory listing for unique filename - El Forum - 07-16-2012 [eluser]skunkbad[/eluser] I've got some code here, which is checking a directory listing to see if there is a unique filename before upload. It's different than the Upload library's check, because it can be used with the FTP class or cURL. I'll be replacing a function in Community Auth with this one tomorrow morning, and thought it may be useful to some of you. If you see or experience any problems, let me know. Expected output is a unique filename. For instance, if uploaded file is named a.pdf, and there is already an a.pdf, the returned filename is a(2).pdf. If a(2).pdf also exists, the returned filename is a(3).pdf, and so on. Code: /** |