Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.