在页面中已经存在帖子的帖子表单方法

时间:2013-10-31 14:48:57

标签: php forms post methods jcrop

我的php页面中有一个post方法,一旦页面被创建就会被调用。现在我在同一页面上有一个表单,当您单击它时,它应该使用裁剪的图像“刷新”页面。当我运行时,我的屏幕上出现了奇怪的文字:

首发方法:

if($_SERVER['REQUEST_METHOD'] == 'POST') {

if($_FILES['afbeelding']['error'] == 0) {
    $imageinfo = getimagesize($_FILES['afbeelding']['tmp_name']);
    if(filesize($_FILES['afbeelding']['tmp_name']) > 204800) {?> <script type="text/javascript"> alert("Maximale bestandsgrootte: 200KB"); window.location = "/inside.php"</script> <?php }
    else{
    move_uploaded_file($_FILES['afbeelding']['tmp_name'], 'images/' . $_FILES['afbeelding']['name']);}

表格:

<form method="post" action="?action=showCrop">
        <input type="hidden" name="x" value="" />
        <input type="hidden" name="y" value="" />
        <input type="hidden" name="w" value="" />
        <input type="hidden" name="h" value="" />
        <input type="hidden" name="image" value="images/<?php echo $_FILES['afbeelding']['name']; ?>" />
        <input type="submit" value="Verklein afbeelding!" name="submit"/>
    </form>
    <?php
    echo '<img src="getimage.php?file=images/' . $_FILES['afbeelding']['name'] . '">';

提交表单后应该调用的方法:

function showCrop(){
$targ_w = $_POST['w'];
$targ_h = $_POST['h'];
$jpeg_quality = 90;

$src = $_POST['image'];
$ext = end(explode(".", $_POST['image']));
switch($ext)
{
  case 'jpg';
  $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;
  break;
  case 'png';
  $img_r = imagecreatefrompng($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/png');
  imagepng($dst_r,null,8);
  exit;
  break;              

} }

0 个答案:

没有答案