uberweiss Posted October 23, 2008 Share Posted October 23, 2008 Hi. I've made a script that upload to folder on my webserver who do i check the file name and if the file exists change it. for instance. coc.xls exist so i want it to be named coc1.xls.. next file has to be named coc2.xls and so on. and where should i put the code? im a bit of a php newbie, so thanks in advance. i've pasted my code in: <?php $path = "C:\web\www-root\www.eurogiro.com\html\joomla\upload";//Sti til mappen filen skal uploades i! $filename = "coc.xls";//Filens navn $httproot = "";//http://www.eurogiro.com/upload/ roden til mappen som filen skal uploades til. if(count($_POST)>0)//Der bliver postet til scriptet { $file = $_FILES['file']; if(move_uploaded_file($file['tmp_name'], $path."/".$filename)) { echo 'The file has been succesfully uploaded'; } else { echo 'The file wasnt uploaded. Please try again'; } } else { $form = '<form enctype="multipart/form-data" action="" method="post"> <input type="file" name="file" value=""><br> <input type="submit" name="submit" value="Upload"> </form>'; echo $form; } echo "</body> </html>"; ?> Link to comment https://forums.phpfreaks.com/topic/129767-check-and-rename-if-file-exist-on-upload/ Share on other sites More sharing options...
GKWelding Posted October 23, 2008 Share Posted October 23, 2008 look up the file_exists() function on Google. Link to comment https://forums.phpfreaks.com/topic/129767-check-and-rename-if-file-exist-on-upload/#findComment-672753 Share on other sites More sharing options...
uberweiss Posted October 24, 2008 Author Share Posted October 24, 2008 tried that didn't help me that much.. I need a bit more help that that... sry Link to comment https://forums.phpfreaks.com/topic/129767-check-and-rename-if-file-exist-on-upload/#findComment-673613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.