Jump to content

is there any wrong with my code here


janim

Recommended Posts

i wanna change the name of existing files in upload

$checkfilename= "select id from $table where file='".$POST['file']."';";
$qryname=mysql_query($checkfilename) or die ("Could not match data because ".mysql_error());
$num_file= mysql_num_rows($qryname);
if ($num_file != 0 ){

$newfilename =  "A" . $oldfile ."" ;
} else {
$newfilename=$oldfile;
}

but nothing happend

it change the file name once

when i upload file named index.php for the second time =Aindex.php but after this it's overwrite the existing files

any comment

thanks

Link to comment
https://forums.phpfreaks.com/topic/63968-is-there-any-wrong-with-my-code-here/
Share on other sites

do you update the 'file' field in your database?

no in my DB it's store the $oldfile

my code was  like this

if ($num_file != 0 ){

$newfilename =  "A" . $oldfile ."" ;
} else {
$newfilename=$oldfile;
}

the $oldfile saved in my DB but it's save it again and again

I think you need to show more code for me to understand exactly what you are doing. From What I can see it seems like you are checking for the original file name, changing it, then looking for the new file name where the old file name is, but I could be wrong because I don't see this code.

yes that's close

i want to upload files in folder called upload

so the name of this file stores in DB with file field

ok ?

the name of file could be similar to another so the sys. gonna overwrite it

ok ?

i want check from DB in file field if the file is exist or not

if yes

change this file name to A+original name and so on

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.