Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

hta access question

I'm running a script that allows the user to upload a picture. The code works as far as the way that it fires in a testing environment, but when I try it live, I'm getting an internal Server Error:

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


When I look at my error log, it's referring to the htaccess file. I've run into this before, but I've forgotten how to solve it.

What's wrong with it and how do I fix it?
Apache Server at tidewaterretirement.com Port 80
Avatar of Papertrip
Papertrip
Flag of United States of America image

Show us what "it" is and maybe we can help ;)
Avatar of Dave Baldwin
You might be asking for something that isn't supported on Godaddy.  Run 'phpinfo()' on your hosting and check to see that the functions you're using are supported.
Avatar of Bruce Gust

ASKER

Here's the code:

 
<?php 
session_start(); 
if (@$_SESSION['auth'] != "yes")                   
{
header("Location: default.php");
exit();
}
 
include ("../carter.inc");

function jpgResizeFrom( $filename, $width, $height, $newFilePath, $quality=75 ) { 
if ( file_exists( $filename ) && !is_dir( $filename ) ) { 
// Get current dimensions and calculate the best size
list($widthOrig, $heightOrig) = getimagesize($filename);

if ( $heightOrig > 0 ) {

$ratioOrig = $widthOrig/$heightOrig;

if ( ($width/$height) > $ratioOrig)
	 $width = $height * $ratioOrig;
else
	 $height = $width / $ratioOrig;


// Resample the original image
//
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);


// Output to a file and clear memory of the old images
//
imagejpeg($image_p, $newFilePath, $quality);
//imagedestroy($image_p);
//imagedestroy($image);

} 

} // if file_exists
}
 
$target = "../Photos/"; 
$target = $target . basename( $_FILES['photo']['name']) ;
$url = basename($_FILES['photo']['name']); 

 
if(!move_uploaded_file($_FILES['photo']['tmp_name'], $target))  header("Location: photo_noupload.php");
else 
{
 
 
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$insert = "update bio set formal_pic='$url' where id ='$_POST[bio_id]'";
$insertexe = mysqli_query($cxn, $insert)
or die ("Couldn't execute query.");
}

//make a thumbnail
$width = 160;  // pixels
$height = 100;   // pixels 
$newFilePath = '../thumbs/';
$imageFolder = '../Photos';
$fileParts = pathinfo( $url );
$filename  = $fileParts['filename'];
$extension = strtolower( $fileParts['extension'] );
$origName  = "$imageFolder/$filename.$extension";
$newName   = "$newFilePath/$filename.$extension"; 
if ( $extension == "jpg" || $extension == "jpeg" || $extension=="JPEG" || $extension=="JPG" ) {
jpgResizeFrom( $origName, $width, $height, $newName );
 }

?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Retirement Guys of Tidewater | Casual Picture Upload</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="../AC_RunActiveContent.js" language="javascript"></script>
<script type="../text/javascript" src="swfobject.js"></script>
<link href="../stylesheet.css" rel="stylesheet" type="text/css" />
<script language="JavaScript"> 
 
<!--
 window.resizeTo(550,600)
 -->
 </SCRIPT>
</head>


<table width="500">
<tr>
<td>&nbsp;<BR>
Here's the picture you just uploaded...!
<P>
Thanks!
<P>
</td>
</tr>
<tr>
<td>&nbsp;<BR>
<HR>&nbsp;<BR>
</td>
</tr>
<tr>
<td>
	<table>
	<tr>
	<td>
	<IMG SRC="../Photos/<?php echo $url; ?>" width="200">
	</td>
	</tr>
	</table></form>

</body>
</html>

Open in new window


Sometimes it works, sometimes it doesn't. It will work with this picture (one of man an woman in winter garb), but then it won't work with the picture of the guy in the suit.

Weird.

The error log reference the htaccess file, but why that doesn't happen every time, I don't understand. User generated imagegary.jpg
OK, I broke things down to some bare bones dynamics and I"m hoping somebody can go, "Oh - that's what the issue is."

Here's my form when that starts this whole thing:

 
<form enctype="multipart/form-data" action="mini_formal_execute.php" method="Post">
	<table>
	<tr>
	<td>
	Photo
	</td>
	<td>
	<input name="photo" type="file" size="60">
	</td>
	</tr>
	<tr>
	<td colspan="2"><input type="hidden" name="bio_id" value="<?php echo $the_id; ?>">&nbsp;<BR>
	<input type="Submit" value="Submit">
	</td>
	</tr>
	</table></form>

Open in new window


Nothing to it, right?

OK, now look a this...

<?php
session_start();
if (@$_SESSION['auth'] != "yes")                  
{
header("Location: default.php");
exit();
}
 
include ("../whatever.inc");
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");

echo "hello";

?>

Again, this only happens when I try to upload the photo of the guy in the suit. But the fact that I'm getting a server error when all I'm attempting to do is say, "Hello" rules out configuration issues, I'm thinking, but I don't know what else could be the problem.

Thoughts?
Just to clarify: All I'm doing on the other end of the form is echoing the word, "hello" and I'm getting the server error -  but only when I try to upload the photo of the guy in the suit. When I do a different photo, I'm OK, but it's not consistent.

What's the problem?
In

if (@$_SESSION['auth'] != "yes")  

remove the @.

http://us3.php.net/manual/en/language.operators.errorcontrol.php
Hey, folks!

I think I'm on the threshold of fixing this.

After talking with godaddy and elaborating on the error messages I've been getting, they seem to think that since I'm running PHP 5, the php.ini file needs to be updated to a php5.ini file.

Question is: How?

I've been going through the web and it would appear that all I need to do is rename the file to php5.ini, but I wanted to run that past some ninjas whose counsel would allow me the opportunity to do this right the first time.

So, how do I set up a php5.ini file?
You normally just add the parts that you need to change in a 'php5.ini' in your web root.  

But!! It's better than that!!  http://community.godaddy.com/system-alerts/?ci=42512  A notice that uploads over 128KB are having problems right now!!
Man, Dave, that's good news. I could not for the life of me figure out what was going on.

Still, let me repeat back to you what you mentioned about the php.ini file. If I take the content that is currently sitting on the php.ini file and rename it to php5.ini and add any of the other parameters that I might want to include, I'm good, correct?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yo, Dave! I changed the php.ini file but it didn't make any difference.

Still, I'm thinking it was a good move in that I am running PHP5. The bottom line is that article you referenced to me. I just got off the phone with godaddy and they confirmed that they are working on it and hopefully it will be solved soon!

Thanks!
Just got off the phone with godaddy again and this time I was directed to my control panel where I changed a configuration with php that was affecting uploads that take a little more time.

Problem solved, problem solved!

Thanks, Dave!
You're welcome, glad to help.