Error sending some photos

1

I made a script that uploads a photo to the server and saves the name in MySQL, but some photos it does not send, some 3 mega pixels type JPEG is not sent and gives error.

index.php:

<form action="upload.php" method="POST" enctype="multipart/form-data">
   <div>
        <label for="foto">Foto do Perfil</label>
        <input type="file" id="foto" name="foto">
        <button type="submit" >enviar</button>
   </div>
</form>

upload.php:

<php
session_start();
$email = $_SESSION['email'];
include_once("../../assets/tools/config.php");
$nome_temporario = $_FILES["foto"]["tmp_name"];
$nome_real = $_FILES["foto"]["name"]; 
copy($nome_temporario,"../../assets/userPic/$nome_real");
$foto = $_FILES['foto']["name"];
$url = $base_url."assets/userPic/".$foto; 
//atualizar no BD
$sql = "UPDATE users SET  foto='$url' WHERE email='$email'";
$salvar = mysqli_query($conn, $sql);
//Verificar se salvou no banco de dados
if(mysqli_affected_rows($conn)){
    $_SESSION['msg'] = "<div class='alert alert-success'>Perfil atualizado com sucesso! 
    <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>";
    header("Location: ./");
} else {
    $_SESSION['msg'] = "<div class='alert alert-danger'> Erro ao atualizar seu perfil! :(
    <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>";
    header("Location: ./");
}
    
asked by anonymous 02.07.2018 / 20:34

2 answers

2

Well it's probably a setting on your php.ini

Search your php.ini for these settings:

post_max_size
upload_max_filesize

And change them to a higher number, after change, try again to insert an image.

    
02.07.2018 / 22:33
2

It may be something of a configuration, when it will check what kind of image can go up it should also put the maximum size allowed, I have a snippet in codeigniter that would be:

$config['upload_path'] = './public/images/noiva';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 2000;
$config['max_width'] = 1024;
$config['max_heigth'] = 768;

I would have to see what it would look like in PHP root.

    
02.07.2018 / 21:36