Sign in to follow this  
MatsK

[web] Server error caused by htaccess!

Recommended Posts

MatsK    394
I'm unable to upload files using Internet Explorer 8, so I tried:

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


but it returns empty!

Then I created an htaccess file;

[code]php_value upload_max_filesize 30M[/code]


I suspect my webserver be on a Unix system, so I used a program called [url="http://www.thefreecountry.com/tofrodos/index.shtml"]tofrodos[/url] to change the linebreaks to a Unix format. But no matter what I do, I get:

[code][color=#000000]
[b]Server error![/b]
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].


[b]Error 500[/b]
[url="http://gpartner.no/"]gpartner.no[/url]
[size=2]Wed Jun 8 09:39:10 2011
[/size][/color]
[size=2][i]Apache/2.2.16[/i][/size][/code]


Help! :(

Share this post


Link to post
Share on other sites
0x3a    109
[quote name='MatsK' timestamp='1307520377' post='4820831']
I suspect my webserver be on a Unix system, so I used a program called [url="http://www.thefreecountry.com/tofrodos/index.shtml"]tofrodos[/url] to change the linebreaks to a Unix format. But no matter what I do, I get:
[/quote]

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


[quote name='MatsK' timestamp='1307520377' post='4820831']
php_value upload_max_filesize 30M[/quote]

Try:
[code]
php_value upload_max_filesize "30M" [/code]

Share this post


Link to post
Share on other sites
MatsK    394
Thanks!

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

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

[font="sans-serif"][size="2"][code]$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");[/code][/size][/font]


[code]
$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/" . [/size][/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");[/size][/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.");[/size][/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");
}[/code]

[font="sans-serif"][size="3"]On Internet Explorer 8, the above ALWAYS fails with UPLOAD_ERR_INI_SIZE as the errorcode. [/size][/font]

Share this post


Link to post
Share on other sites
MatsK    394
[font=Tahoma, Arial, Helvetica, sans-serif][size=2]I also checked [/size][/font][font=Tahoma, Arial, Helvetica, sans-serif][size=2]POST_MAX_SIZE, and it also set to 64m o_O[/size][/font]

Share this post


Link to post
Share on other sites
rip-off    10979
[quote]
... 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.

[quote]
... is this a problem with Internet Explorer? o_O
[/quote]
Why, is it working using another browser?

Share this post


Link to post
Share on other sites
MatsK    394
Ya, it works perfectly in Google Chrome, and I'd assume also in Firefox.

[quote][color="#1C2837"][size="2"]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][/size][/color]
[color="#1C2837"] [/color]
[color="#1C2837"][size="2"]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![/size][/color]
[color="#1C2837"] [/color]
[color="#1C2837"][size="2"]Edit: Setting the value doesn't work in another browser, but uploading does.[/size][/color]

Share this post


Link to post
Share on other sites
rip-off    10979
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this