Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_FILES)
- {
- //echo '<pre>';print_r($_FILES);
- /*
- Array
- (
- [files] => Array
- (
- [name] => earth_and_moon-1280x800.jpg
- [type] => image/jpeg
- [tmp_name] => C:\xampp\tmp\php5E88.tmp
- [error] => 0
- [size] => 134688
- )
- )
- */
- $filename0=$_FILES['files']['name'];
- copy($_FILES['files']['tmp_name'],'1.tmp');
- // Content type
- $filename="1.tmp";
- $max=580;
- // Get new dimensions
- list($width, $height) = getimagesize($filename);
- if($width>$height)
- {
- $persen=$width/$max;
- }else{
- $persen=$height/$max;
- }
- $width1=$width/$persen;
- $height1=$height/$persen;
- $x0=(600-$width1)/2;
- $y0=(600-$height1)/2;
- //die("$x0, $y0, 0, 0, $width1, $height1, $width, $height);");
- $new_width = 600;
- $new_height = 600;
- // Resample
- $image_p = imagecreatetruecolor($new_width, $new_height);
- $white = imagecolorallocate($image_p, 255, 255, 255);
- imagefill($image_p, 0, 0, $white);
- $image = imagecreatefromjpeg($filename);
- imagecopyresampled($image_p, $image,
- $x0, $y0, 0, 0,
- $width1, $height1, $width, $height);
- // Output
- header('Content-Type: image/jpeg');
- header('Content-Disposition: attachment; filename="'.$filename0.'"');
- imagejpeg($image_p, null, 100);
- die();
- }
- ?><!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <? /* <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
- <script src="../js/jquery-1.8.2.js"></script>
- <script src="../js/kendo.all.js"></script>
- <link href="styles/kendo.common.css" rel="stylesheet" />
- <link href="styles/kendo.default.css" rel="stylesheet" />
- */
- ?></head>
- <body>
- <div class='myform' >
- <form enctype='multipart/form-data' method="post" >
- Masukkan File
- <input name="files" id="myfiles" type="file" />
- <p>
- <input type="submit" value="Perbesar Gambar" class="k-button" />
- </form>
- </div>
- <!--
- <div id="example" class="k-content">
- <form method="post" action="" style="width:45%">
- <div>
- <input name="files" id="files" type="file" />
- <p>
- <input type="submit" value="Submit" class="k-button" />
- </p>
- </div>
- </form>
- <script>
- $(document).ready(function() {
- $("#files").kendoUpload();
- });
- </script>
- </div>
- -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement