Users input jpg files to an existing db table after using a resize function. Sometimes the images are reversed so I found code to rotate jpg’s with SimpleImage. The rotated jpg’s are saved to the same /uploads folder as the original jpg’s. I want to move the jpg from the /uploads folder to the db table. I can get the code to move all the existing table data with $_SESSION but not the jpg data.
Here is code for rotating the jpg
<?php
session_start();
$image_name = $_SESSION['image_name'];
$file = '//WDP/DFS/30/1/0/8/3067916801/user/sites/4232274.site/www/uploads/';
$angle = $_POST['Radio1'];
include_once '//WDP/DFS/30/1/0/8/3067916801/user/sites/4232274.site/www/require/SimpleImage.php';
// Ignore notices
error_reporting(E_ALL & ~E_NOTICE);
try {
// Create a new SimpleImage object
$image = new claviska\SimpleImage();
// Manipulate it
$image
->fromFile($file.$image_name) // load .jpg
->autoOrient() // adjust orientation based on exif data
->bestFit(300, 600) // proportinoally resize to fit inside a 300 x 600 box
->flip($angle) // flip
->toFile($image_name) // output to file
->toScreen(); // output to the screen
} catch(Exception $err) {
// Handle errors
echo $err->getMessage();
}
?>
Here is code snippet which gets original jpg to the db table just fine. Like I said, I need to get the jpg now from the /uploads folder to the same db table to replace that original jpg. In other words, the source for the rotated jpg is not the website user but the /uploads folder. If only I could have the user search the /uploads folder for the jpg file through a browse field. Or, is there another solution? I’ve come up with two, but much less elegant solutions.