techker Posted November 12, 2018 Share Posted November 12, 2018 Hey guy's i have a script i did a few months ago and now noticed that it is doing its job but keeps the old file ..so i got the image a few times but on a different angle... how can i optimize this code to delete the old image when doing the rotation? <?php session_start(); include_once 'dbconnect.php'; if (!isset($_SESSION['userSession'])) { header("Location: index.php"); } $degrees = -270; $path = $_GET['Folder']; $file =$_GET['Pic']; $fileid =$_GET['id']; $image = $path.'/'.$file; $imageN = $path.'/New_'.$file; //load the image $source = imagecreatefromjpeg($image); //rotate the image $rotate = imagerotate($source, $degrees, 0); $NewImg='New_'.$file ; //set the Content type //header('Content-type: image/jpeg'); //display the rotated image on the browser //imagejpeg($rotate); imagejpeg($rotate,$imageN,100); //free the memory imagedestroy($source); imagedestroy($rotate); $sql = "UPDATE Coupon_list SET product_image_thumb = '$NewImg' WHERE id = '$fileid'"; if (mysqli_query($DBcon, $sql)) { echo "Rotation ok"; echo('<script language="Javascript">opener.window.location.reload(false); window.close();</script>'); } else { echo "Error Rotating: " . mysqli_error($DBcon); } mysqli_close($DBcon); ?> <img src="gears.gif" alt="" /> Link to comment Share on other sites More sharing options...
requinix Posted November 12, 2018 Share Posted November 12, 2018 The source image is a filename contained in the $image variable, right? Link to comment Share on other sites More sharing options...
techker Posted November 22, 2018 Author Share Posted November 22, 2018 correct Link to comment Share on other sites More sharing options...
requinix Posted November 22, 2018 Share Posted November 22, 2018 Okay, so... problem solved? Link to comment Share on other sites More sharing options...
techker Posted November 22, 2018 Author Share Posted November 22, 2018 ya i think just need to unlink the old file Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.