Source for file index.php

Documentation is available at index.php

  1. <?php
  2. /**
  3.  * Aptana Cloud Sample Application - Image Manipulation Demo
  4.  * 
  5.  * This is just a simple, single-page app showing off file uploads and image manipulations using the imagick
  6.  * extension for PHP.  Feel free to modify this code in any way, or re-use it in one of your apps
  7.  * if you would like.
  8.  * 
  9.  * The basic process followed by the application is:
  10.  * 
  11.  *  - Upload an image file to the 'uploads' directory
  12.  *  - Open the image, and resize it
  13.  *  - Apply some effects via imagick to create a "polaroid" effect
  14.  *  - Save the resulting image
  15.  *  - Show the resulting image to the user
  16.  *  
  17.  * For more information about imagick, check out the PHP docs for the extension:
  18.  * {@link http://us3.php.net/manual/en/intro.imagick.php PHP imagick documentation}
  19.  * 
  20.  * Also see Mikko's blog for the code that inspired this sample, as well as more imagick
  21.  * goodness:
  22.  * {@link http://valokuva.org/?p=42 Mikko's Blog}
  23.  * 
  24.  * @author Ian Selby
  25.  * @version 1.0
  26.  * @license http://www.opensource.org/licenses/mit-license.php MIT License
  27.  * @package ImageManipulationDemo
  28.  * @filesource
  29.  */
  30.  
  31. /**
  32.  * Helper functions for the sample app
  33.  */
  34. include_once('functions.inc.php');
  35.  
  36. // upload the file if the form has been submitted and then process the image
  37. if(isset($_POST['doUploadFile']))
  38. {
  39.     $result uploadImage('file2upl');
  40.     
  41.     if($result['success'])
  42.     {
  43.         $new_file generatePolaroidImage(SITE_ROOT 'uploads/' $result['filename']);
  44.     }
  45. }
  46.  
  47. ?>
  48. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  49. <html>
  50. <head>
  51.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  52.     <title>Image Manipulation Demo</title>
  53.     
  54.     <style type="text/css">
  55.     
  56.         body { 
  57.             color: #333;
  58.             font-family: "Lucida Grande", Arial, Helvetica, sans;
  59.             font-size: 12px;
  60.             margin: 0;
  61.             padding: 10px;
  62.         }
  63.         
  64.         a { color: #0080ff; }
  65.         
  66.         p { line-height: 16px; }
  67.         
  68.         .footer {
  69.             font-size: 10px;
  70.             margin-top: 10px;
  71.             text-align: center;
  72.         }
  73.     
  74.     </style>
  75. </head>
  76. <body>
  77.  
  78. <?php if(!isset($_POST['doUploadFile']))?>
  79.  
  80. <h1>Sample Image Manipulation</h1>
  81.  
  82. <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
  83. <p>
  84.     <label for="file2upl">Choose a File to Upload:</label><br />
  85.     <input type="file" name="file2upl" id="file2upl" /><br />
  86.  
  87.     <button type="submit">Submit</button>
  88.     
  89.     <input type="hidden" name="doUploadFile" value="1" />
  90.     
  91.  
  92. </p>
  93. </form>
  94.  
  95. <?php else?>
  96.  
  97.     <?php if($result['success'])?>
  98.     <h1>Uploaded File</h1>
  99.     <img src="uploads/<?php echo $new_file?>" />
  100.     <br />
  101.     <a href="index.php">Upload another image...</a>
  102.     
  103.     <?php else?>
  104.     <h1>Error</h1>
  105.     <?php echo $result['error']?><br />
  106.     <a href="index.php">Try again...</a>
  107.     
  108.     <?php endif?>
  109.  
  110. <?php endif?>
  111.     
  112. <div class="footer">
  113.     <a href="docs/index.html">View Documentation and Source for This Sample</a>
  114. </div>
  115. </body>
  116. </html>

Documentation generated on Tue, 07 Oct 2008 15:23:02 -0700 by phpDocumentor 1.4.2