Skip to content Skip to sidebar Skip to footer

How To Save Uploaded Image Names In Mysql Database

Part of this answered question I have beneath php code which upload one cropped image to 3 different width and height in avatar directory with width and height 200*200 avatar1 di

Solution 1:

copyImageFile('avatar1', $sTempFileName, 500, 500);
copyImageFile('avatar2', $sTempFileName, 700, 700);

replace this code after

include('connect/mysql.php');
    $avatar1=copyImageFile('avatar1', $sTempFileName, 500, 500);
    $avatar2=copyImageFile('avatar2', $sTempFileName, 700, 700);
$user_name = mysqli_real_escape_string($con, $_SESSION['UserName']);

       mysqli_query($con,"UPDATE profiles SET AvatarImage='".$sResultFileName."',AvatarImageBig='".$avatar1."',AvatarImageSmall='".$avatar2."' WHERE UserName = '$user_name'");   
        mysqli_close($con);

Solution 2:

Thanks to @Banjamin and @Qaisar

You are using $con in the function

uploadImageFile($user_name),

so you should pass the variable $con to this function, something like

uploadImageFile($user_name, $con) of course then you have to change your functions accepted arguments.

Post a Comment for "How To Save Uploaded Image Names In Mysql Database"