tested_123 Posted June 21, 2008 Share Posted June 21, 2008 i have to rename a file placed inside a folder and i have to rename it using a function and not just have to use "rename" function.i have to make a function like this function rename($dirpath,$oldfilename,$newfilename) and this function must be recursive and a directory can contain subdirectory also.the opration will be like this...... there will a text box where i will enter old file name and in another text box i will enter new file name and when i press submit it will rename that file placed inside that folder........i need it urgently thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/ Share on other sites More sharing options...
DanielWhite Posted June 21, 2008 Share Posted June 21, 2008 Try one of these: rename('/path1/old_filename', '/path2/new_filename'); rename('$OLD', '$NEW'); rename('.$OLD.', '.$NEW.'); rename($OLD, $NEW); Sorry my PHP isn't the best. Good Luck :-) Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/#findComment-570849 Share on other sites More sharing options...
tested_123 Posted June 21, 2008 Author Share Posted June 21, 2008 i have to do it using recursive function which i have written above Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/#findComment-570852 Share on other sites More sharing options...
DanielWhite Posted June 21, 2008 Share Posted June 21, 2008 Do these pages help? http://www.phpro.org/examples/Recursively-Rename-All-Files-In-Directory-With-RecursiveDirectoryIterator.html http://lixlpixel.org/recursive_function/php/manual/function.rename.html http://www.bensfriends.com/theideaman/archives/2006/12/28/rename_files_recursively_in_linuxunix.html Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/#findComment-570853 Share on other sites More sharing options...
tested_123 Posted June 21, 2008 Author Share Posted June 21, 2008 thanx for the link .................one link out of them can help me .........let me see if it works for me or not Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/#findComment-570858 Share on other sites More sharing options...
tested_123 Posted June 21, 2008 Author Share Posted June 21, 2008 no that links are not working as needed...........wat i want is i there will be two text boxes in first i will enter old file name and in other text box i will enter new and when i press submit it must change the old filnename to new file name in a directory Quote Link to comment https://forums.phpfreaks.com/topic/111222-rename-a-file-using-php/#findComment-570869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.