View Single Post
  #1 (permalink)  
Old March 16th, 2010, 05:36 PM
rickymartini76@yahoo.it rickymartini76@yahoo.it is offline
Authorized User
 
Join Date: Dec 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy Chapter 7 - Exercise

Hello all, i have some problem with caption on chapter 7, code is exact and i believe that the problem is th GD file on php that don't load arial caracter...
How i can resolve this problem?

Moreover, Can I have some help about 7.1 exercise?
Code is next, file vacation.htm:

Code:
<html>
 <head>
  <title>Go on a Virtual Vacation!</title>
 </head>
 <body>
  <form method="post" action="upload_image.php" enctype="multipart/form-data">
   <table>
    <tr>
     <td><label for="image_caption">Image Name or Caption</label><br/>
      <em>Example: Wish you were here!</em></td>
     <td><input id="image_caption" name="image_caption" type="text" size="55"/></td>
     </tr><tr>
      <td><label for="image_username">Your Name:</label></td>
      <td><input id="image_username" name="image_username" type="text" size="15"></td>
     </tr><tr>
      <td><label for="image_filename">Upload Image:</label></td>
      <td><input id="image_filename" name="image_filename" type="file" /></td>
     </tr>
    </table>
    <p><em>Acceptable image formats include: JPG/JPEG</em></p>
    <p>Select your destination:</p>
    <table>
     </tr><tr>
      <td><input type="radio" id="destination_1" name="destination" value ="beach" /></td>
      <td><label for="destination_1"><img src="images/beach.jpg"></label></td>
     </tr><tr>
      <td><input type="radio" id="destination_2" name="destination" value ="golfcourse" /></td>
      <td><label for="destination_2"><img src="images/golfcourse.jpg">
     </label></td>
     </tr><tr>
      <td><input type="radio" id="destination_3" name="destination" value ="mountains" /></td>
      <td><label for="destination_3"><img src="images/mountains.jpg"></label>
      </td>
     </tr>
    </table>
    <p style="text-align: center">
     <input type="submit" name="Submit" value="Submit" />
     <input type="reset" value="Clear Form" /></p>
    </form>
   </body>
  </html>
And upload_image.php file is :

Code:
<?php
// Filtra le variabili in arrivo
$image_caption = (isset($_POST['image_caption'])) ? $_POST['image_caption'] : '';
$image_username = (isset($_POST['image_username'])) ? $_POST['image_username'] : 'Anonymous';
$destination = $_POST['destination'];
$image_tempname = $_FILES['image_filename']['name'];
$today = date('Y-m-d');

// Modificare questo percorso in base alla directory che contiene le immagini
$dir ='C:/Programmi/Apache Software Foundation/Apache2.2/htdocs/images';

$image_name = $dir . $image_tempname;

if (move_uploaded_file($_FILES['image_filename']['tmp_name'], $image_name))
{
   // Recupera le informazioni sull'immagine che sta per essere inviata
   list($width, $height, $type, $attr) = getimagesize($image_name);
   
   if ($type != IMAGETYPE_JPEG) {
       echo '<p><strong>Sorry, but the file you uploaded was not a JPG ' .
            'file.<br/>Please hit your back button and try again.</strong></p>';
   } else {
      // L'immagine è accettabile, si può procedere
       $dest_image_name = $dir . $destination . '.jpg';

       $image = imagecreatefromjpeg($image_name);
       list($width2, $height2, $type2, $attr2) = getimagesize($dest_image_name);

       $image2 = imagecreatefromjpeg($dest_image_name);
       imagecopymerge ($image2, $image, 0,0,0, 0, $width, $height, 100);
   }

   header('Content-type:image/jpeg');
   imagejpeg($image2);
}
?>
When first file call upload_image.php there is next Error message:
Warning: getimagesize(C:/Programmi/Apache Software Foundation/Apache2.2/htdocs/imagesbeach.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php on line 27

Warning: imagecreatefromjpeg(C:/Programmi/Apache Software Foundation/Apache2.2/htdocs/imagesbeach.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php on line 29

Warning: imagecopymerge(): supplied argument is not a valid Image resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php on line 30

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php:27) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php on line 33

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\upload_image.php on line 34

Thank you for your helps….
Reply With Quote