Jump to content

Problem with picture upload after upgrading PHP to ver.5.3.27


Tomislav

Recommended Posts

 

in your original code, after the two exec(....) statements that resized/cropped the image, you had the remainder of your code that processed the form data? you still need for that code to run.

 

change this -

   if (imagejpeg($canvas, "/home2/smiztita/public_html//images/content/" . $slika . '.jpg', 100)) {

       return true;

   } else {

       return false;

   }

to this (note that i added a ! to complement the conditional test) - 
   if (!imagejpeg($canvas, "/home2/smiztita/public_html//images/content/" . $slika . '.jpg', 100)) {


      // do something here when this process fails - some application error reporting/logging perhaps...

   }

Thank you a million times. It finally works !

 

Now, the only thing that is left is cropper tool, it loads and works well, but when cropped picture is saved, it still remains the same picture.

But if that can't be solved never mind.

 

Here is cropper.php script :

 

<?php    

    if (isset($_GET['h'])) $max_height = $_GET['h']; else $max_height = 1000;                

    $path = '/images/content/'

?>

<script type="text/javascript" src="/javascript/cropper/lib/prototype.js"></script>

<script type="text/javascript" src="/javascript/cropper/lib/scriptaculous.js?load=builder,dragdrop"></script>

<script type="text/javascript" src="/javascript/cropper/cropper.js"></script>

<?php

    list($cur_width, $cur_height) = getimagesize(getenv('DOCUMENT_ROOT').$path.'o_'.str_replace('m_', '', (str_replace('v_', '', $_GET['slika']))));    

    $max_width = 480;

    if ($cur_width > $max_width)

    {        

        $width = $max_width;

        $coef = $max_width / $cur_width;

        $height = round($cur_height * $coef);    

    }

    else

    {    

        $width = $cur_width;

        $coef = 1;

        $height = $cur_height;        

    }

?>

<script type="text/javascript">

<!--

    var coef = <?php print $coef; ?>;

                

    function onEndCrop( coords, dimensions )

    {

        $( 'x1' ).value = Math.round(coords.x1 / coef);

        $( 'y1' ).value = Math.round(coords.y1 / coef);

        $( 'x2' ).value = Math.round(coords.x2 / coef);

        $( 'y2' ).value = Math.round(coords.y2 / coef);

        $( 'width' ).value = Math.round(dimensions.width / coef);

        $( 'height' ).value = Math.round(dimensions.height / coef);    

    }

 

Event.observe( window, 'load', function() {

        new Cropper.Img(

            'fotografija',

            {                 

                min_width: <?php print $_GET['w']; ?>,                

                <?php

                    if (isset($_GET['h']))

                    {

                ?>        min_height: <?php print $max_height; ?>,

                        <?php

                            if (isset($_GET['q']) && $_GET['q'] != 'proizvodi')

                            {

                        ?>

                            ratioDim: { x: <?= $_GET['w']; ?>, y: <?= $_GET['h']; ?> },

                <?php

                            }

                    }

                ?>    

                displayOnInit: true,

                onEndCrop: onEndCrop

            }

        );

} );

 

-->

</script>

 

<div id="fotka">

<img src="<?= $path.'o_'.str_replace('m_', '', (str_replace('v_', '', $_GET['slika']))); ?>" alt="<?= $_GET['slika']; ?>" id="fotografija" style="width:<?php print $width; ?>px; height:<?php print $height; ?>px; float:none; " />

</div>

<?php if ($coef < 1) { ?><p class="bad_alert">Prikaz fotografije je <?php print number_format(($coef * 100),1,',','.'); ?>% njene stvarne veličine.</p><?php } ?>

<form id="forma" action="index.php" method="post" enctype="multipart/form-data">

    <fieldset>

<input type="hidden" name="q" value="<?php print $_GET['q']; ?>" />

<input type="hidden" name="id" value="<?php print $_GET['id']; ?>" />

<input type="hidden" name="slika" value="<?php print $_GET['slika']; ?>" />

<input type="hidden" name="h" value="<?php if(isset($_GET['h'])) print $_GET['h']; ?>" />

<input type="hidden" name="w" value="<?php print $_GET['w']; ?>" />

<label for="cur_width">trenutna širina</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="cur_width" id="cur_width" size="4" class="tekst kratki" value="<?php print $cur_width; ?>" />

<label for="cur_height">trenutna visina</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="cur_height" id="cur_height" size="4" class="tekst kratki" value="<?php print $cur_height; ?>" />

<label for="width">označena širina</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="width" id="width" size="4" class="tekst kratki" />

<label for="height">označena visina</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="height" id="height" size="4" class="tekst kratki" />

<label for="x1">x1</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="x1" id="x1" size="4" class="tekst kratki" />

<label for="y1">y1</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="y1" id="y1" size="4" class="tekst kratki" />

<label for="x2">x2</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="x2" id="x2" size="4" class="tekst kratki" />

<label for="y2">y2</label>

<input type="text" onkeypress="return disableEnterKey(event)" name="y2" id="y2" size="4" class="tekst kratki" />

<label for="submit"> </label>

<input type="hidden" name="todoaction" />

<input type="submit" id="save" name="save" class="btn" style="margin-top:20px;" value="spremi" onclick="document.getElementById('forma').todoaction.value='save';" onkeypress="document.getElementById('forma').todoaction.value='save';" />

</fieldset>

</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.