// create a new image from file $vImg = @imagecreatefromgif($sTempFileName); break;*/ case IMAGETYPE_PNG: $sExt = '.png'; // create a new image from file $vImg = @imagecreatefrompng($sTempFileName); break; default: @unlink($sTempFileName); return; } // create a new true color image $vDstImg = @imagecreatetruecolor($iWidth, $iHeight); // copy and resize part of an image with resampling imagecopyresampled($vDstImg, $vImg, 0, 0, (int) $_POST['x1'], (int) $_POST['y1'], $iWidth, $iHeight, (int) $_POST['w'], (int) $_POST['h']); // define a result image filename $sResultFileName = $sTempFileName . $sExt; // output image to file imagejpeg($vDstImg, $sResultFileName, $iJpgQuality); @unlink($sTempFileName); return $sResultFileName; } } } } } } $sImage = uploadImageFile(); echo '<img src="' . $sImage . '" />';
<?php if (!empty($_POST['note'])) { require_once '././lib/functions/upload_image.php'; if ($_FILES) { $upload_pic = uploadImageFile($_FILES["image_file"], $user_data['ID']); } //print_r($upload_pic); if ($upload_pic != '') { $mysqldate = date('Y-m-d H:i:s', time()); $diary_note = mysql_real_escape_string($_POST['note']); //insert new entry $diary = new ModifyEntry(); $diary->table = $tbl_diary; $diary->cols = 'userID, entry, date, picture'; $diary->values = " '" . $user_data['ID'] . "', '" . $diary_note . "', '" . $mysqldate . "', '" . $upload_pic . "' "; $diary->insert(); unset($diary); } header("Location:" . ROOT_DIR . "improve/diary/index.html"); } elseif (!empty($_POST['submit_del'])) { $del_diary_entry = new ModifyEntry(); $del_diary_entry->table = $tbl_diary; $del_diary_entry->condition = "userID = '" . $user_data['ID'] . "' && ID = '" . $_POST['id_to_delete'] . "' "; $confirm_del = $del_diary_entry->delete(); if ($confirm_del === true && $_POST['pid'] != '') { $path = 'media/images/uploads/' . $user_data['ID'] . '/' . $_POST['pid']; $i_full = explode(".", $_POST['pid']); $path_full = 'media/images/uploads/' . $user_data['ID'] . '/' . $i_full[0] . '_full.' . $i_full[1]; unlink($path); //delete thumbnail