How would I add an exclusion to all files and folders except .mp3?
-
<?php $dirpath="./"; $handle = opendir($dirpath); print '<div id="response"></div>'; print "<table>"; $i=0; while($file = readdir($handle)) { if($file!="." && $file!="..") { print "<tr><td><input type='text' id='{$i}_new_name' value='{$file}' /></td><input type='hidden' id='{$i}_old_name' value='{$file}' /></td><td><input type='button' name='change' class='change_class' value='Change Name' id='{$i}' /></td></tr>"; $i++; } } print "</table>"; ?>
-
Hey @MPG-Radio
Thanks for the tip!
Here is an example on how to check if a file name ends with the extension .mp3
Let me know if you need help getting it to work in your code.
$src_file_name = 'something.MP3'; $ext = strtolower(pathinfo($src_file_name, PATHINFO_EXTENSION)); // Using strtolower to overcome case sensitive $mp3 = 'mp3'; if (strcasecmp($ext, $mp3) == 0) { echo "it's mp3"; } else { echo 'not mp3'; }
So maybe something like this:
<?php $dirpath="./"; $handle = opendir($dirpath); print '<div id="response"></div>'; print "<table>"; $i=0; while($file = readdir($handle)) { $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $mp3 = 'mp3'; if($file!="." && $file!=".." && strcasecmp($ext, $mp3) == 0 ) { print "<tr><td><input type='text' id='{$i}_new_name' value='{$file}' /></td><input type='hidden' id='{$i}_old_name' value='{$file}' /></td><td><input type='button' name='change' class='change_class' value='Change Name' id='{$i}' /></td></tr>"; $i++; } } print "</table>"; ?>
-
Hey @MPG-Radio
Thanks for the tip!
Here is an example on how to check if a file name ends with the extension .mp3
Let me know if you need help getting it to work in your code.
$src_file_name = 'something.MP3'; $ext = strtolower(pathinfo($src_file_name, PATHINFO_EXTENSION)); // Using strtolower to overcome case sensitive $mp3 = 'mp3'; if (strcasecmp($ext, $mp3) == 0) { echo "it's mp3"; } else { echo 'not mp3'; }
So maybe something like this:
<?php $dirpath="./"; $handle = opendir($dirpath); print '<div id="response"></div>'; print "<table>"; $i=0; while($file = readdir($handle)) { $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $mp3 = 'mp3'; if($file!="." && $file!=".." && strcasecmp($ext, $mp3) == 0 ) { print "<tr><td><input type='text' id='{$i}_new_name' value='{$file}' /></td><input type='hidden' id='{$i}_old_name' value='{$file}' /></td><td><input type='button' name='change' class='change_class' value='Change Name' id='{$i}' /></td></tr>"; $i++; } } print "</table>"; ?>
-
All is well now thank your efficient help...works just fine.....
-
Ok shoot, my php version must be a problem I cant seem to change the name nothing happens when I click the change name button but works fine on local machine....humm.
-
Ok my bad was serving over https.....duh...thank you.