View Full Version : file case rename issue

11-22-2010, 02:21 PM
i was going to post this in apache forum here but when i clicked on the link it gave me a db error on your site.. so ill post it here...

i understand by default that the servers normally are set to accept both uppercase and lowercase names as unique, and i have checked with my host and yes it does, however in my php file when i do a rename of a file it tells me the file already exists and i checked and there is no lowercase function used, so not sure why it will not accept the unique difference between uppercase and lowercase file names.. ..

11-22-2010, 02:56 PM
Is your host a Windows or Linux machine? Windows does not differentiate between upper and lower case but Linux does.

11-22-2010, 03:03 PM
its a linux, its got me puzzled lol

11-22-2010, 03:05 PM
Your question is pretty ambiguous. You need to post some code or something that can be reproduced.

11-22-2010, 03:27 PM
ok here is where i pull them from the db and the post values

$filename = strip_tags($db->f('filename'));
$filepath = strip_tags($db->f('filepath'));
$oldpath = $filepath;

if (isset($_POST['newname'])) {
$newpath = mysql_escape_string($_POST['newpath']);
$newname = mysql_escape_string($_POST['newname']);
$longname = "$newpath$newname";

and then i do a few if statements to make sure its the same filepath dir and the input is not null, then i update the db with the new info then i rename the file in the directory

rename ("$filepath$filename", "$newpath$newname");

but even if the $oldname is lowercase and the $newname is uppercase it tells me the file already exists.

11-22-2010, 04:02 PM
i may have found it, when i do the compare one file name to new file name, im checking the db values not the input values, so naturally it will be the same..

if im correct i need to compare the input data, that way it can be unique uppercase or lowercase on the compare...

but im not sure how to write uppercase name to the db value.. or is that a given ( i mean will it write the value as is, however its input upper or lower) ill have to test that..

11-22-2010, 05:36 PM
The database doesn't give a monkeys what case you supply. It inserts it as is. You ought to be prepending a unique identifier to each file, to limit the probability of two filenames ever matching. Use the current timestamp, a randomly generated string etc.