1
I use the code below and it works correctly, but I need that during UPLOAD the image name is changed.
<?php require_once('conexao.php'); ?>
<?php
$cliente = $_GET['cliente'];
$cod = $_GET['cod'];
$uploaddir = "./clientes/".$cliente."/".$cod."/";
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
$imvfoto = $_FILES['uploadfile']['name'];
$sqlgravar="INSERT INTO fotos(cod,cliente,foto)
VALUES ('$cod','$cliente','$imvfoto')";
$resultadogravar = mysql_query($sqlgravar)
or die (mysql_error());
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "success";
} else {
echo "error";
}
include("resize-class.php");
$resizeObj = new resize("/home/roteirodoimovelc/public_html/cp/clientes/".$cliente."/".$cod."/".$imvfoto."");
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> resizeImage(600, 450, 'exact');
$resizeObj -> saveImage("/home/roteirodoimovelc/public_html/cp/clientes/".$cliente."/".$cod."/".$imvfoto."", 100);
?>
How do I make this implementation so that the photo is renamed and saved to the server and also to the database?
he doesn’t take the extension
– Gladison Neuza Perosini
The current example in the answer that generates a unique ID, and takes the extension.
– Bacco