3
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 image quality, because I’m working on a site like Instagram and I need the images to be very light, with Facebook does. Captures the image and converts she to JPG and reduces the size of the image MB for KB
From now on I thank you all...
Right, I used a script similar to this, but the script will be run in the folder localweb PROJECT Conn server.php and it saves the image in the same folder where php was run, when I need it to send to *localweb PROJECT image posts* , and another using your script, how to ask if it was sent to such a folder as mine
if(move_uploaded_file($sourcePath,$caminho_imagem))
– Pedro Quezado
@When this script is set to the path for the image. If you want to save your image in a different location, use the function
move_uploaded_file
to change the directory image, after changing the location, call the script by passing the current image directory.– Filipe Moraes