| | |
Help, If You Can Find My Error! Exhausted Again
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2006
Posts: 52
Reputation:
Solved Threads: 0
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
/> 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!
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
/> 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
- i neeed ur help .. find error in data structure program (C++)
- program error for cd burner program (Windows NT / 2000 / XP)
- Can't find the error (C)
- help me find the error (C++)
- find out the error in my code (Java)
- Lotus notes error: #0c:04 (Networking Hardware Configuration)
- Bridge.dll error (Viruses, Spyware and other Nasties)
- iexplorer.exe send error reports(1 too many) (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: how to open a jpg from mysql database
- Next Thread: Show Last IP
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube






