Log in

View Full Version : Checking list



jfreak53
07-28-2009, 03:10 PM
I have this list that is being passed to a PHP page from a java program, the list looks like this:


file1.jpg,file2.jpg,file3.jpg,etc

What I want to do is go through that list and find files in the list that have illegal characters in their names, like spaces and others, and rename the files after being changed to characters to something like "_". Could I have some help on this please? I kind of figure it would have to be converted into an array, then sorted or something of the sort.

Thanks in advance.

jfreak53
07-30-2009, 05:51 PM
Ok all done here is my code for that:


if(ftp_chdir($conn, $www.$images)) {

$export = str_replace($_REQUEST['baseDir']."\\\\", "", $_REQUEST['f']);

$list = explode("#,#", $export);

for($i = 0; $i < sizeof($list) - 1; $i++)
{
$extension = ".".substr(strrchr($list[$i], '.'), 1);
$fileName = RemoveExtension($list[$i]);
ftp_rename($conn, $list[$i], filename_safe($fileName).$extension);
}

This gets the list, explodes it replaces all characters and basedir originally in list and then renames file on server without the bad extensions.

Thanks for everyones help.