Jump to content

rafael.munareto

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

0 Comum

About rafael.munareto

  1. Pessoal, No código abaixo quero recortar a foto e subir o nome do arquivo na variável que busco no banco de dados, consegui fazer o efeito de recortar e de visualizar mas não está aparecendo a imagem recortada e nem salvando o nome do arquivo com a nova dimensão, podem me ajudar: <?php error_reporting(E_ALL ^ E_NOTICE); require_once("mostra-alerta.php"); include("coneta_mysql.php"); /** * Jcrop image cropping plugin for jQuery * Example cropping script * @copyright 2008-2009 Kelly Hallman * More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targ_w = $targ_h = 150; $jpeg_quality = 90; $src = "img/perfil/<?php echo $foto_perfil ; ?>"; $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], $targ_w,$targ_h,$_POST['w'],$_POST['h']); header('Content-type: image/jpeg'); imagejpeg($dst_r,null,$jpeg_quality); exit; } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>REDE A</title> <link rel="icon" href="img/logo_pequeno.png"> <link href="css/principal.css" rel="stylesheet" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link href="css/select2.min.css" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet"> <link rel="stylesheet" href="css/bootstrap.min.css"> <script src="js/principal.js"></script> <script src="js/jquery.min.js" type="text/javascript"></script> <script src="js/jquery.Jcrop.js" type="text/javascript"></script> <script src="js/jquery.Jcrop.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" /> <link rel="stylesheet" href="css/demos.css" type="text/css" /> </head> <script type="text/javascript"> jQuery(function($){ // Create variables (in this scope) to hold the API and image size var jcrop_api, boundx, boundy; $('#cropbox').Jcrop({ onChange: updatePreview, onSelect: updatePreview, aspectRatio: 1 },function(){ // Use the API to get the real image size var bounds = this.getBounds(); boundx = bounds[0]; boundy = bounds[1]; // Store the API in the jcrop_api variable jcrop_api = this; }); function updatePreview(c) { if (parseInt(c.w) > 0) { var rx = 100 / c.w; var ry = 100 / c.h; $('#preview').css({ width: Math.round(rx * boundx) + 'px', height: Math.round(ry * boundy) + 'px', marginLeft: '-' + Math.round(rx * c.x) + 'px', marginTop: '-' + Math.round(ry * c.y) + 'px' }); } }; $(function(){ $('#cropbox').Jcrop({ aspectRatio: 1, onSelect: updateCoords }); }); function updateCoords(c) { $('#x').val(c.x); $('#y').val(c.y); $('#w').val(c.w); $('#h').val(c.h); }; function checkCoords() { if (parseInt($('#w').val())) return true; alert('Please select a crop region then press submit.'); return false; }; }); </script> <body> <main> <?php include("conecta_mysql.php"); require_once("logica-usuario.php"); include("foto_perfil_php.php");?> <div id="outer"> <div class="jcExample"> <div class="article"> <table> <tr> <td> <img id="cropbox" alt="Flowers" src="img/perfil/<?php echo $foto_perfil ; ?>" style="width: 100%; margin-right: 2rem"> </td> <td> <div style="width:100px;height:100px;overflow:hidden;"> <img src="img/perfil/<?php echo $foto_perfil ; ?>" id="preview" alt="Preview" class="jcrop-preview" /> </div> </td> </tr> </table> <form action="alterar_imagem.php" method="post" onsubmit="return checkCoords();"> <input type="hidden" id="x" name="x" /> <input type="hidden" id="y" name="y" /> <input type="hidden" id="w" name="w" /> <input type="hidden" id="h" name="h" /> <input type="submit" value="Recortar" /> </form> <form method="post" enctype="multipart/form-data" name="cadastro"> <input class="btn btn-outline-success" id="escolha_foto" type="file" name="foto"> <button type="file" id="button_perfil" class="btn btn-outline-success" name="upload_foto"> OK </button> <button class="btn btn-outline-success" onclick="refresh()">SAIR</button> </form> </div> </div> </div> </main> </body> <?php include('rodape.php') ?>
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.