[web] Server error caused by htaccess!

Started by
5 comments, last by rip-off 12 years, 10 months ago
I'm unable to upload files using Internet Explorer 8, so I tried:

$IniSetting = ini_set('upload_max_filesize', '30971520');
if(empty($IniSetting))
{
echo("Couldn't set upload_max_filesize!");
}



but it returns empty!

Then I created an htaccess file;

php_value upload_max_filesize 30M


I suspect my webserver be on a Unix system, so I used a program called tofrodos to change the linebreaks to a Unix format. But no matter what I do, I get:

[color=#000000]
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the [email="gunnar@gpartner.no"]webmaster[/email].


Error 500
gpartner.no
[size=2]Wed Jun 8 09:39:10 2011

[size=2]Apache/2.2.16



Help! :(
Advertisement

I suspect my webserver be on a Unix system, so I used a program called tofrodos to change the linebreaks to a Unix format. But no matter what I do, I get:


Create a php file with this in it to see what system you are dealing with:
<?php phpinfo(); ?>



php_value upload_max_filesize 30M


Try:

php_value upload_max_filesize "30M"
If I've helped you in any way please push the reputation button, thanks!

Abstraction is my choice of words.
Portfolio: http://www.0x3a.com/
Blog: http://blog.0x3a.com/
Thanks!

phpinfo() says the system is [font="sans-serif"]SystemLinux sheraton 2.6.26-2-686-bigmem #1 SMP Thu Jan 27 01:21:02 UTC 2011 i686
[/font]
[font="sans-serif"]It also says the max_upload_filesize is[/font]
[font="sans-serif"]upload_max_filesize64M64M
[/font]
[font="sans-serif"]Which makes me wonder... is this a problem with Internet Explorer? o_O[/font]

[font="sans-serif"]Here's my upload code:[/font]

[font="sans-serif"]$IniSetting = ini_set('upload_max_filesize', '30971520');
if(empty($IniSetting))

echo("Couldn't set upload_max_filesize!");
}

<form enctype=\"multipart/formdata\" method=\"post\" action=\"upload.php\" align=\"center\">\n");
echo(" <!--30 megs max filesize-->\n");
echo(" <input name=\"MAX_FILE_SIZE\" value=\"30971520\" type=\"hidden\"/>\n");
echo(" <input name=\"UploadedZip\" value=\"Velg zip\" type=\"file\"/><br/>\n");
echo(" <input name=\"MagazineNum\" value=\"Nummer\" type=\"text\"/><br/><br/>\n");
echo(" <input name=\"BtnUploadFile\" value=\"Last opp fil\" type=\"submit\"/><br/>\n");
echo(" </form>\n");
[/font]



$IniSetting = ini_set('upload_max_filesize', '30971520');
if(empty($IniSetting))
{
echo("Couldn't set upload_max_filesize!");
}


if(move_uploaded_file($_FILES['UploadedZip']['tmp_name'], $ZipTargetPath))
{
if($_FILES['UploadedZip']['error'] > 0)
{
echo("Error: " . (string)$_FILES['UploadedZip']['error']);
EchoError("Error");
return;
}

if($_FILES['UploadedZip']['type'] == 'application/zip' || $_FILES['UploadedZip']['type'] == 'application/stuffit')
{
echo("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
echo("<html>");
echo("<head>");
echo(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n");
echo(" <title>Agder N&aeligring</title>\r\n");
echo(" <meta name=\"description\" content=\"\">");
echo(" <meta name=\"keywords\" content=\"agder nring industri grafisk partner\">\r\n");
echo(" <meta name=\"author\" content=\"Mats Vederhus\">\r\n");
echo(" <meta name=\"generator\" content=\"AceHTML Freeware\">\r\n");

echo(" <link rel=stylesheet href=\"login-style.css\">\r\n");
echo("</head>\r\n");

echo("<body>");
echo(" <p class=\"CenteredImage\"><img src=\"/agdernering/Agdernering-silver.PNG\" alt=\"\"></p>\n");
echo(" <div class=\"Menu\" align=\"center\">\n");
echo(" <ul>\r\n");
echo(" <li><a href=\"index.php\">Hjem</a></li>\n");
echo(" <li><a href=\"contact.html\">Kontakt</a></li>\n");[
echo(" <li><a href=\"login.php\">Login</a></li>\n");
echo(" <li><a href=\"mags.php\">Magasiner</a></li>\n");
echo(" </ul>\n");
echo(" </div>\n");
echo("<p class=\"CenteredText\"><b>Filen " . basename($_FILES['UploadedZip']['name']) . " har blitt lastet opp!</b></p>");
echo("</body>");
echo("</html>");

$Connection = mysql_connect($DatabaseAddress, "gpartner", "removed");

if(!$Connection)
{
die("mySQL error" . mySQL_error() . "\n");
}

mysql_select_db("gpartner", $Connection);

$ZipHandler = zip_open($ZipTargetPath);

if($ZipHandler)
{
while($ZipEntry = zip_read($ZipHandler))
{
//strpos returns boolean false if needle wasn't found.
if(ContainsNumbers(zip_entry_name($ZipEntry)) !== false && strpos(zip_entry_name($ZipEntry), 'Agder') !== false)
{
$ImgBuf = zip_entry_read($ZipEntry, zip_entry_filesize($ZipEntry));
$ImageTargetPath = 'PDFs/' . zip_entry_name($ZipEntry);

$ImgHandle = fopen("PDFs/" . zip_entry_name($ZipEntry), "w");
fwrite($ImgHandle, $ImgBuf);
fclose($ImgHandle);

break;
}]
}[
}
//TODO: Zip error?

$ImgSize = getimagesize($ImageTargetPath);

$StrNews = basename($_FILES['UploadedZip']['name'], ".zip") . "' har blitt lastet opp, du kan lese det n&aring!<br/>";
$StrMag = "<a href=\"http://gpartner.no/agdernering/generatemags.php?Magazine=" . basename($_FILES['UploadedZip']['name'], ".zip") . "\"><img src=\"" . "http://gpartner.no/agdernering/" . [/font]
$ImageTargetPath . "\" " . ImageResize($ImgSize[0], $ImgSize[1], 170) . " alt=\"\"/></a>";

if($Debug == true)t]
{
mysql_query("INSERT INTO agdernnewsitems (Date, NewsItem) VALUES('" . mysql_real_escape_string(date("d/m/Y h:i:s a", time())) . "','" . mysql_real_escape_string($StrNews) . "')", $Connection);]
}

mysql_query("INSERT INTO agdernreleasedmags (MagazineID, MagazineLink) VALUES('" . mysql_real_escape_string($MagazineNum) . "','" . mysql_real_escape_string($StrMag) . "')", $Connection);

mysql_close($Connection);
}
else
{
EchoError("Type");[/font]
}
else
{
if ($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_INI_SIZE)
{
echo("The UPLOAD_ERR_INI_SIZE error code means the size of the uploaded file is larger than the value specified by the upload_max_filesize directive.");
}
else if($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_FORM_SIZE)
{
echo("The UPLOAD_ERR_FORM_SIZE error code never appears if there is no MAX_FILE_SIZE hidden field in the HTML/XHTML form that contains the <input type=\"file\"> element.");
}
else if($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_PARTIAL)

echo("The UPLOAD_ERR_PARTIAL error code means the server only receives part of the uploaded file.");
}
else if($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_NO_FILE)
{
echo("The UPLOAD_ERR_NO_FILE error code means the HTTP request contains no uploaded file.");
}
else if($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_NO_TMP_DIR)
{
echo("The UPLOAD_ERR_NO_TMP_DIR error code means there is no temporary directory.");[/font]
}
else if($_FILES['UploadedZip']['error'] == $UPLOAD_ERR_CANT_WRITE)
{
echo("The UPLOAD_ERR_CANT_WRITE error code means the uploaded file cannot be written to disk.");
}

EchoError("Error");
}


[font="sans-serif"]On Internet Explorer 8, the above ALWAYS fails with UPLOAD_ERR_INI_SIZE as the errorcode. [/font]
[font=Tahoma, Arial, Helvetica, sans-serif][size=2]I also checked [/font][font=Tahoma, Arial, Helvetica, sans-serif][size=2]POST_MAX_SIZE, and it also set to 64m o_O[/font]

... but it returns empty!
[/quote]
The documentation page for ini_set has a comment at the end saying that if it returns "empty" then a script cannot set the value.


... is this a problem with Internet Explorer? o_O
[/quote]
Why, is it working using another browser?
Ya, it works perfectly in Google Chrome, and I'd assume also in Firefox.

[color="#1C2837"]The documentation page for ini_set has a comment at the end saying that if it returns "empty" then a script cannot set the value.[/quote]
[color="#1C2837"]
[color="#1C2837"]I am painfully aware of this. But since the phpinfo() seems to think that the ini is set to 64m, I shouldn't need to set the value in the first place!
[color="#1C2837"]
[color="#1C2837"]Edit: Setting the value doesn't work in another browser, but uploading does.
So in IE 8, you cannot upload any files, regardless of size? In other browsers, you can upload files to the limit provided?

Examine the headers of the request, see what the Content-Length being sent is. You may want to look at this from IE8's side too.

This topic is closed to new replies.

Advertisement