php-on-apache-upload big-size

A

Anonymous

Guest
Hi,

I have an domain on a server where is Apache Web Server and Php.

I made a site that it is hosted by that server but not only mine it is there, of course.

I want to be able to upload big files, I mean like 35 Mega or something, from admin area of my site, so user can download them (the client asks for this).

Maybe up to 60 M. With php I upload the files. I know that from script I cannot set the upload size with ini_set, I tried to put a .htaccess in the upload folder, with:

php_value upload_max_filesize "100M"

php_value post_max_size "100M"

php_value memory_limit "100M"

php_value max_execution_time "600"

upload_max_filesize="100M"

post_max_size="100M"

memory_limit="100M"

max_execution_time=600

but didn't work.

After this I talked with a guy from the support and he put all this settings in httpd.conf and I see it in local values and get them right, except memory_limit, with

print 'post_max_size = ' . ini_get('post_max_size') . "<br>";
print 'upload_max_filesize = ' . ini_get('upload_max_filesize') . "<br>";
print 'memory_limit = ' . ini_get('memory_limit') . "<br>";
print 'max_execution_time = ' . ini_get('max_execution_time') . "<br>";

and are correct, 100M. But still cannot upload more than 2 mega file.

What is the problem? Or is there another way?

Regards,
Adrian

PS: the code also:

...<?
if($HTTP_GET_VARS['id']){
$work_id = $HTTP_GET_VARS['id'];
}else{
$work_id = $HTTP_POST_VARS['id'];
}
if($HTTP_POST_VARS['submit']){

if(is_mixed(trim($HTTP_POST_VARS['name']))){

$sql = "Select * from files where name = '" . trim($HTTP_POST_VARS['name']) . "' and workarea_id = " . $work_id;
$nrc=db_query($sql);
if ($nrc && db_numrows($nrc) > 0) {
$feedback .= "<span class=\"c12Red\"> Already exists a file with this name in this workarea.</span><br>";
} else {

$userfile_error = $_FILES['userfile']['error'];

if ($userfile_error > 0)
{
echo 'Problem: ';
switch ($userfile_error)
{
case 1: $feedback .= 'File exceeded upload_max_filesize'; break;
case 2: $feedback .= 'File exceeded max_file_size'; break;
case 3: $feedback .= 'File only partially uploaded'; break;
case 4: $feedback .= 'No file uploaded'; break;
}
}

if(!$feedback){

if (is_uploaded_file($_FILES['fisier']['tmp_name'])) {

if(!is_dir("../" . $the_path . "/" . $work_id)){
mkdir("../" . $the_path . "/" . $work_id,0755);
chmod ("../" . $the_path . "/" . $work_id,0775);
}

if(move_uploaded_file($_FILES['fisier']['tmp_name'
], "../" . $the_path . "/" . $work_id . "/" . $_FILES['fisier']['name'])){
}else{
$feedback .= "Could not move the file: " . $_FILES['fisier']['tmp_name'];
}

} else {
$feedback .= "Possible file upload attack. Filename: " . $_FILES['fisier']['tmp_name'];
}

}

if(!$feedback){

$sql="Insert into files (name,workarea_id,file_path) Values('" . trim($HTTP_POST_VARS['name']). "'," . $work_id . ",'" . $the_path . "/" . $work_id . "/" . $_FILES['fisier']['name'] . "')";
$nrc=db_query($sql);
if (!$nrc || db_affected_rows($nrc) < 1) {
$feedback .= "<span class=\"c12Red\"> Error: " .db_error() . " sql: " . $sql . "</span";
} else {
$feedback .= "<span class=\"c12red\"> File Added </span>";
}


}

}
}
?><span class="c12Red"><?=$feedback?></span><?
}
?>
<br>
<br>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<form name="addfile" onsubmit="return validateForm(this)" enctype="multipart/form-data" method="post" action="<?=$PHP_SELF?>">
<tr>
<td width="100" class="c12black">File Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td width="100" class="c12black">The file</td>
<td><input type="file" name="fisier"></td>
</tr>
<tr>
<td width="100" height="30"> </td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="102400000">
<input type="hidden" name='id' value="<?=$work_id?>">
<input type="submit" name="submit" value="submit">
</td>
</tr>
<tr>
<td colspan="2">
<span class="c12black1">[ <a href="files.php?id=<?=$work_id?>" class="c12black1">Back</a> ]</span>
</td>
</tr>
</form>
</table>
...
 
These need to be in php.ini, not httpd.conf or .htaccess. And don't forget to restart the web server.
 
1. can be in httpd.conf

2. I do not have access to php.ini :) The php.ini is for all domains and they do not want to change it, and I understand that.

http://coderforums.com/archive/topic/1740-1.html

I tried like this and still doesn't work! is something wrong with my code perhaps?
 
I stand corrected.

Apache also has its own maximum upload size (independent from PHP), which may set in httpd.conf (LimitRequestBody). I'm not sure what the default is, but I'm sure it's probably in the 2-8mb range. While you may be able to change this in .htaccess, even considering uploading a 100mb file via the web browser is crazy. Even 10mb is pushing it -- browsers aren't designed to sustain connections for more than a few minutes at a time, or to send HTTP requests that big, nor is the HTTP protocol itself.
 
It worked, yes, with .htaccess with this lines in it:

<Limit GET POST>
php_value upload_max_filesize "100M"
</Limit>

php_value post_max_size "100M"

php_value memory_limit "100M"

php_value max_execution_time "600"

This file should be in the folder where the script is.

PS: I know that uploading more than 10 megs on web browser is crazy but on one hand the client desired :) and second is that also the client I think will upload maxim some mp3s.

so...
 
Back
Top