944,045 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1328
  • PHP RSS
Jun 3rd, 2006
0

Help, If You Can Find My Error! Exhausted Again

Expand Post »
I have tried and again I cannot figure it out. Everything is working...

Only the jpg, JEPG like these do not show up correctly... Can you see the mistake? If you do please spell it out for me. Much appreciated, again, puddin.

Here is my form and process photo code:

_________________________
THIS IS THE FORM
_________________________

<?php
include 'db.php';

// initialization
$photo_upload['aphoto_filename'];
$counter = 1;

if( $_GET['number_of_fields'] )
$number_of_fields = (int)($_GET['number_of_fields']);


// Lets build the Photo Uploading fields
while( $counter <= $number_of_fields )
{
$photo_upload;

__HTML_END;
$counter++;
}
// Final Output
echo <<<__HTML_END

<!-Insert the photo fields here -->
$photo_upload
<html>
<head>
<title>Lets upload Photos</title>
</head>

<body>
<table class="image" cellpadding="1" cellspacing="0">
<tr>
<td>
<form name="photo_filename" action="photo1.php" method="post" enctype="multipart/form-data">
<font color=#FFFFFF><b>
Photo:
<input name="aphoto_filename[]" type="file">
Caption: <textarea name='namea' cols='20' rows='1'></textarea>
<input type='submit' name='submit' value='Add Photos'/>
<input type="HIDDEN" name="$session_name" value="$session_id"></font>
</form>
</td>
</tr>
</table>
</body>
</html>
__HTML_END;
?>




________________________________________________________
THIS IS IT'S 2nd PAGE PROCESS THAT STORE'S IT AND DISPLAYS
________________________________________________________

<?php
include 'db.php';

// initialization
$result_final = "";
$counter = 0;
// List of our known photo types
$known_photo_types = array(
'image/pjpeg'=>"jpg",
'image/jpeg'=>"jpg",
'image/jpg'=>"jpg",
'image/png'=>"png",
'image/x-png'=>"png",
'image/gif'=>"gif",
'image/bmp'=>"bmp"
);

// GD Function List
$gd_function_suffix = array(
'image/pjpeg' => 'JPEG',
'image/jpeg' => 'JPEG',
'image/gif' => 'GIF',
'image/bmp' => 'WBMP',
'image/x-png' => 'PNG'
);
// Fetch the photo array sent by preuploads.php
$photos_uploaded = $_FILES['aphoto_filename'];


// Fetch the photo caption array
$_POST['namea'];

while( $counter <= count($photos_uploaded) )
{

if($photos_uploaded['size'][$counter] > 0)
{
if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
{
$result_final .= "File ".($counter+1)." is not a photo<br />";

}else{

// get the variables from home page
$password = $_SESSION['password'];
$email_address = $_SESSION['email_address'];

$sql_update = mysql_query("UPDATE myd SET aphoto_filename='".($filename)."',
namea='".($namea)."' WHERE email_address='".($email_address)."' AND password='".($password)."'" );
$filetype = $photos_uploaded['type'][$counter];
$extention = $known_photo_types[$filetype];
$filename = $namea.".".$extention;


$sql_update = mysql_query("UPDATE myd SET aphoto_filename='".($filename)."',
namea='".($namea)."' WHERE email_address='".($email_address)."' AND password='".($password)."'" );

$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){

echo ("");
} else {
echo ("");
}
// Store the orignal file
copy($photos_uploaded['tmp_name'][$counter], $images_dir."/$name_".$filename );

// Let's get the Thumbnail size
$size = GetImageSize( $images_dir."/".$filename );
if($size[0] > $size[1])
{
$thumbnail_width = 100;
$thumbnail_height = (int)(100 * $size[1] / $size[0]);
}

else
{

$thumbnail_width = (int)(100 * $size[0] / $size[1]);
$thumbnail_height = 100;
}

// Build Thumbnail with GD 1.x.x, you can use the other described methods too
$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = "ImageCreateFrom".$function_suffix;
$function_to_write = "Image".$function_suffix;

// Read the source file
$source_handle = $function_to_read ( $images_dir."/$name_".$filename );

if($source_handle)
{
// Let's create an blank image for the thumbnail
$destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height );

// Now we resize it
ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width,


$thumbnail_height, $size[0], $size[1] );
}

// Let's save the thumbnail
$function_to_write( $destination_handle, $images_dir."/$name_".$filename );


$result_final .= "<img src='".$images_dir. "/$name_".$filename."' /> <br

/>&nbsp;&nbsp; Photo ".($counter+1)." ";
}
}
$counter++;
}

echo <<<__HTML_END

<html>
<head>
<title>Photos uploaded</title>
</head>
<body>

$result_final
</font>
</body>
</html>
__HTML_END;
?>
</p>

Gifs come up perfect but not JPEGS, Please I Am NEW At PHP CLEAR CODE INSTRUCTION IS REALLY APPRECIATED, Thanks soooo Much, puddin!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
puddin is offline Offline
52 posts
since Mar 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to open a jpg from mysql database
Next Thread in PHP Forum Timeline: Show Last IP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC