Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried to reproduce your issue. However, I couldn't. I made some changes to my world but I believed to cover everything you posted.</p> <p>Follow my example:</p> <p>index.php</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="upload.php" enctype="multipart/form-data" method=post&gt; &lt;input type="file" id="f_up" name="f_up"&gt; &lt;input type="submit" value=go&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>upload.php</p> <pre><code>&lt;?php require_once('masterclass.php'); if (!empty($_FILES)){ require_once('masterclass.php'); $galeria = $_POST['gal']; $fecha = $_POST['fecha']; $titulo = $_FILES['f_up']['name']; $imagen = $_FILES['f_up']['tmp_name']; $mc = new masterclass; $mc-&gt;saveImage($imagen, 800, 600, 80); } </code></pre> <p>masterclass.php</p> <pre><code>&lt;?php class masterclass{ public function saveImage($tmpImagen, $maxWidth, $maxHeight, $quality){ $db = mysql_connect('127.0.0.1','root') or die('could not connect'); mysql_select_db('examples',$db); $origen = imagecreatefromjpeg($tmpImagen); if( isset($tmpImagen, $maxWidth, $maxHeight, $quality) ){ //$fecha = $this-&gt;formatFecha($fecha); // format date string $origen = imagecreatefromjpeg($tmpImagen); $x = imagesx($origen); $y = imagesy($origen); if( $x &gt; $maxWidth ){ $nx = $maxWidth; $ny = $y*$nx/$x; } if( $y &gt; $maxHeight ){ $ny = $maxHeight; $nx = $x*$ny/$y; } else{ $nx = $x; $ny = $y; } $destino = imagecreatetruecolor($nx,$ny); imagecopyresized($destino,$origen,0,0,0,0,$nx,$ny,$x,$y); imagejpeg($destino, $tmpImagen, $quality); $imagen = addslashes(fread(fopen($tmpImagen, "rb"), filesize($tmpImagen))); $peticion = "insert into upload_image (image) values ('$imagen')"; mysql_query($peticion,$db) or die('error'); } else{ die($this-&gt;isError(2)); } } } </code></pre> <p>This code works fine on mysql 5.5.27 and PHP 5.3.15. Let us know a little more about your environment. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload