Wideimage and Mysql and PHP

Asked

Viewed 189 times

0

Good morning! So I’ve got a boring problem here.

$nome_produto       = $_POST['nome'];
$valor_produto      = moeda_mysql($_POST['valor']);
$categoria_produto  = $_POST['categoria'];
$descricao_produto  = $_POST['descricao'];
$estoque_produto    = $_POST['estoque'];

$sql = "INSERT INTO `produtos` 
(`id`, `nome`, `descricao`, `valor`, `id_categorias`, `estoque`) 
VALUES 
    (NULL, 
    '$nome_produto', 
    '$descricao_produto', 
    '$valor_produto', 
    '$categoria_produto',
    '$estoque_produto')";

$query      = log_mysqli_query($a, $sql);
$id_produto = mysqli_insert_id($a);

if($query) {

// Diretório de Upload de Imagens 
$diretorio      = 'imagens/produtos/';  

require_once 'wideimage/WideImage.php';

// Nome temporário de upload
$tmp_name = $_FILES['imagem']['tmp_name'];

// Carrega a imagem a ser manipulada                
$image = WideImage::load($tmp_name);
$image = $image->resize(300, 300);

// Nome
$imagem = $diretorio.$id_produto.".".$extencao;
// Salva imagem
$image->saveToFile($imagem);


$sql = "UPDATE `produtos` SET
        `foto_nome` = '$imagem'
        WHERE `id` = '$id_produto'";

$query = log_mysqli_query($a, $sql);

I run the script without the require_once, require, include, already tested all of these, Wideimage, and runs normally, saved in BD. I need to upload and resize, I want to send the file straight from the temp to the Wide, do the resizing and then save to the server. It doesn’t work out the way it is, and I can’t see the mistake.

Thanks in advance

  • Syntax, really no error. When running this script returns some message?

  • Check the logs for any errors and edit the post by adding the logs.

  • @rzani Then, it goes to the first query, saves the INSERT in the database, but does not save the image by the class, nor does the UPDATE

  • @Inkeliz PHP Warning: POST Content-Length of 14208098 bytes Exceeds the limit of 3145728 bytes in Unknown on line 0, I changed the max_post_size to 32mb, and persists the same, has several errors of these different, referring to the different images that I tried to upar.

  • 1

    I believe that the ideal is to save the image in some direct (maybe non-public) and then save in the database only the name of the saved file. But to solve the error of POST should change the post_max_size and the upload_max_filesize. The limit is set to 3.14MB, while the uploaded file has 14.2MB. Change both variables to 33554432, this is equivalent to 32MB in Bytes. Then restart Apache/Nginx only by doubt.

  • @Inkeliz So, as I said above, I changed the post_max_size to 32mb, it was with 3mb. But it did not help, still the same thing. I tested at the same time that I edited, and tested again today with the restarted server. What I am doing there is simple, or was meant to be. I’m taking the file straight from the POST, editing it and saving it on the server. Then it saves the way. It should work.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.