I need help perfecting a script .. In general I want to add to this script:
if(isset($_POST['action']) && $_POST['action'] == 'get_photo') {
if(is_array($_FILES)) {
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$file_name = $_FILES['userImage']['name'];
$sourcePath = $_FILES['userImage']['tmp_name'];
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $file_name, $ext);
// Gera um nome único para a imagem
$nome_imagem = md5(uniqid(time())) . "." . $ext[1];
// Caminho de onde ficará a imagem
$desired_dir="../image/posts/";
$caminho_imagem = $desired_dir.$nome_imagem;
if(move_uploaded_file($sourcePath,$caminho_imagem)) {
echo '<img src="/image/posts/'.$nome_imagem.'" width="100px" height="100px" />';
}
}
}
}
A system or way to reduce the quality of the image, since I'm working on a website like Instagram and I need the images to be quite light, with Facebook does. Capture the image and convert it to JPG and reduce the size of the image to MB for KB
>Thanks in advance for all ...