0

hi all,....

plz help me.....

hi guyz... i just know how to insert a file into database, but i dont know how to update that file....

here is my code....

<?php
        $resume=$_FILES['resume']['name'];
    $file=$_FILES['resume']['tmp_name'];
    $ext=strstr($resume,".");
    //echo "file".$file;
//echo "<br>";
//echo "resume".$resume;
$sql = "SELECT MAX(cnd_id) FROM tbl_candidate";
$res = mysql_query($sql);
$data= mysql_fetch_row($res);
$id = $data[0];
$id = $id+1;

$resumepath = $id.$ext;

//echo $id;
//echo $resumepath;
@move_uploaded_file($file,"http://localhost/tjc%20backup/admin/resume/$resumepath");//file uploading
//echo $email_id;

         $sql="INSERT INTO  tbl_candidate (title,name,surname,contact_phone,email_id,current_employer,key_skills,current_designation,total_experience,relevant_experience, current_location,location_considered,degree, percentage, current_salary,current_benefits,expected_salary, expected_benefits, notice, reason, availability,remarks,extra_remarks,remarks_date,resume,create_date) VALUES ('$title','$name','$surname','$contact','$email_id1','$crnt_employer','$key_skills','$crnt_designation','$ttl_experience','$rel_experience','$crnt_location',
'$loc_considered1".implode(',',$loc_considered)."','$degree','$percentage','$crnt_salary','$crnt_benefits','$exp_salary','$exp_benefits','$notice','$reason','$availability','$remarks','$ext_remarks','$rem_date','$resumepath',CURDATE())";
          $obj->query($sql) or die(mysql_error());
 ?>

Edited by amith_ami

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by amith_ami
0

tnx... urtrivedi
now its working......
here is my new code....

<?php
if(!empty($resumepath)) {
                  $sql = "SELECT resume FROM tbl_candidate WHERE cnd_id =" .$cnd_id;
                   $res = mysql_query($sql);
                    $data= mysql_fetch_row($res); 
                    $res1 = $data[0];
                    $reset = "../admin/resume/$res1";
                    if(file_exists($reset))
                    {
                        unlink($reset);
                    }

                $resume=$_FILES['resume']['name'];
              $file=$_FILES['resume']['tmp_name'];
              $ext=strstr($resume,".");
     $resumepa = $cnd_id.$ext;
 @move_uploaded_file($file,"../admin/resume/$resumepa");

$sql = "UPDATE tbl_candidate SET resume = '".$resumepa."' WHERE cnd_id = $cnd_id";
 $obj->query($sql) or die(mysql_error());
//echo $sql;
                    }
?>                  
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.