Page 1 of 1
Upload zip file larger then 10 M
Posted: Mon Jun 22, 2009 2:57 am
by wpsd2006
Help me... give me some light
I play around with the upload code and try uploading image zipped file, the size larger than 10 Megabyte and it always return below code when uploading ( actually it doesn't upload the picture the text below immediately appear )
Request Entity Too Large
The requested resource
/lh_manager/ajax/ajax_photo.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g Server at localhost Port 80
I already set the setting in php.ini for the post and upload to 50M and memory to 512M
it check the change in phpmyadmin import tab it said max file is (Max: 51,200 KiB)
and i can upload gz type larger than 10MB ( but gz only for text format right ? )
then I try to set it using .htaccess
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
and still the same output
I can upload zip file around 9 MB
so it's kinda like there is a limit of 10MB either in post or upload or zip upload
anybody know how to resize this settings ?
Re: Upload zip file larger then 10 M
Posted: Mon Jun 22, 2009 7:24 am
by patrickmvi
I found the following URL which may help you better understand your issue:
http://www.checkupdown.com/status/E413.html
Can you post a snippet of the code used in ajax_photo.php to do the actual photo upload so that we can review how it's being submitted?
Re: Upload zip file larger then 10 M
Posted: Mon Jun 22, 2009 8:25 pm
by wpsd2006
i check above page, i don't think my page doing some weird stuff while uploading ... this is my code anyway
This is the upload form it's called by ajax
Code: Select all
public static function new_photo($mode = 0) {
$modedata = json_decode(stripslashes($mode));
$html .= '<div style="margin: 0 0 0 0" >';
$html .= '<h3 style="float:left;margin:0 0 15px 0;">Upload Photo</h3>';
$html .= '<span style="float:right;">';
$html .= '<a href="javascript:hide_photo_window();">Close</a>';
$html .= '</span>';
$html .= '</div>';
$html .= '<div class="clearboth"></div>';
$html .= '<div style="float:left;width:350px;margin-bottom:15px">';
$html .= '<iframe style="display:block" id="photo_iframe" name="iframe_upload"></iframe>';
$html .= '<form id="photo_form" method="post" enctype="multipart/form-data" action="ajax/ajax_photo.php" target="iframe_upload" >';
$html .= '<input type="hidden" name="t" value="insertPhoto" />';
$html .= '<input type="hidden" name="unitid" value="'.$modedata->unitid.'" />';
$html .= '<label style="display:block;">Image file (.jpg) or Compressed image folder (.zip) Total max size 40MB</label><br/>';
for($a = 0;$a < 10; $a++) {
$html .= '<input type="checkbox" name="file_'.$a.'" checked><input type="file" style="width:180px" name="new_photo[]" /><br/>';
}
$html .= '<input type="submit" value="Upload" />';
$html .= '</form>';
$html .= '</div>';
$html .= '<div style="float:left;width:250px">';
$html .= '</div>';
return $html;
}
here is my the ajax_photo.php
Code: Select all
case 'insertPhoto':
echo 'test';
$temp = new Photo(0);
$temp->check_photo($_FILES['new_photo'],$_POST);
break;
it called the Photo Class whe upload
the $this->insert_photo_to_db($tempimagedir.$tempimageextract.$imagefile,'rename',$post); only doing database INSERT
unless you need it i not going to write it here
Code: Select all
public function check_photo($file,$post) {
$type = $file['type'];
$error = $file['error'];
foreach($type as $key=>$filetype) {
if(!$error[$key] && $post['file_'.$key] == 'on') {
switch($filetype) {
case 'application/zip':
$tempimagedir = BASE_DIR.'photos/tempimage/';
$tempzipfile = time().'image.zip';
$tempimageextract = time().'image/';
$noerror = move_uploaded_file($file['tmp_name'][$key], $tempimagedir.$tempzipfile);
if($noerror) {
$zip = new ZipArchive;
if ($zip->open($tempimagedir.$tempzipfile) === TRUE) {
$zip->extractTo($tempimagedir.$tempimageextract);
$zip->close();
unlink($tempimagedir.$tempzipfile);
if($handle = opendir($tempimagedir.$tempimageextract)) {
while (false !== ($imagefile = readdir($handle))) {
if ($imagefile != "." && $imagefile != "..") {
$imgext = explode('.',$imagefile);
$ext = end($imgext);
echo $imagefile.' '.$ext.'<br/>';
if($ext == 'jpg' || $ext == 'jpeg' || $ext == 'JPEG' || $ext == 'JPG') {
$this->insert_photo_to_db($tempimagedir.$tempimageextract.$imagefile,'rename',$post);
}
else {
unlink($tempimagedir.$tempimageextract.$imagefile);
}
}
else continue;
}
closedir($handle);
rmdir($tempimagedir.$tempimageextract);
}
}
}
else {
unlink($tempimagedir.$tempzipfile);
}
break;
case 'image/jpg':
case 'image/jpeg':
$this->insert_photo_to_db($file['tmp_name'][$key],'move_upload',$post);
break;
default:
break;
}
}
else continue;
}
}
Re: Upload zip file larger then 10 M
Posted: Tue Jun 23, 2009 3:13 pm
by patrickmvi
It all looks ok to me. The next thing I would try is to make a very simple-stupid upload form which doesn't involve AJAX at all and see if I still have the same problem. That would rule out any potential coding issues. Then if you still have a problem, it would have to be at the server level. You should then run a phpinfo(); from the SAME FOLDER as where you're trying to run your simple upload script and make sure all the values are correct. Beyond that, it could be some sort of web server setting/limitation. Do you know what type of web server this is being run under? Is it Apache?
Re: Upload zip file larger then 10 M
Posted: Tue Jun 23, 2009 8:06 pm
by wpsd2006
well this one doesn't count as ajax,i just use iframe
form method post go to iframe and no ajax things on upload ...
i just happen to put it in the file name with "ajax"
Do you know what type of web server this is being run under? Is it Apache?
Yeah I use LAMP
I develop it for intranet apps so i have all the access to modify the server
do you know which web server setting/limitation i must change other than upload limit, post limit, and memory
The next thing I would try is to make a very simple-stupid upload form which doesn't involve AJAX at all and see if I still have the same problem.
I going to try this one
Re: Upload zip file larger then 10 M
Posted: Tue Jun 23, 2009 8:14 pm
by wpsd2006
No luck, simple upload didn't work either
still return below text:
Request Entity Too Large
The requested resource
/testsite/upload/upload.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
testupload.php
Code: Select all
<form id="photo_form" method="post" enctype="multipart/form-data" action="upload.php" >
<input type="file" name="test" />
<input type="submit"/>
</form>
upload.php
Code: Select all
echo '<pre>';
print_r($_POST);
print_r($_FILES);
echo '</pre>';
I heard there is limitation in zip upload to 10 MB, I can't find how to lift the limit off in the google.
Re: Upload zip file larger then 10 M
Posted: Tue Jun 23, 2009 10:36 pm
by patrickmvi
I really doubt that there is a specific restriction for zip files, I would think the restriction would somehow be apache-based.
Re: Upload zip file larger then 10 M
Posted: Wed Jun 24, 2009 1:34 am
by VladSun
Re: Upload zip file larger then 10 M
Posted: Wed Jun 24, 2009 7:34 pm
by wpsd2006
Yeah i found how to solve it
it's in the apache settings , they limit it because of security purpose
I don't know about windows
but in linux you change the settings in httpd.conf or include it in .htaccess
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 104857600 // this one vary from 0 ( unlimited - they said it's not recommended to use this) to 2 G
</Files>
the LimitRequestBody was set to around 9M last time lol
phew it solved, but i have another problem !@^#%$ Centos php doesn't include php-zip class .......
Re: Upload zip file larger then 10 M
Posted: Fri Jun 26, 2009 2:57 am
by wpsd2006
Ok i finish install zip in centos
so it's all work out not , or so i thought
HELLLLLLLLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPPPP
i got a headache because of this
here's what happen
the web server - the pc that i upload the file into and my web application - OS: Centos
PC1: my computer - OS: Ubuntu - Firefox 3.0.10
PC2: other computer 1 - same as above
PC3: other computer 2 - OS: Windows Vista - Firefox 3.0.10
PC4: other computer 3 - OS: Windows - Firefox 2.0.10 old one
PC5: other computer 4 - OS: Windows Xp - Firefox 3.0.10
PC1 - succeed in uploading zip file ( large zip file )
PC2 - succeed in uploading zip file ( large zip file )
PC3 - failed in uploading zip file ( large zip file )
PC4 - succeed in uploading zip file ( large zip file )
PC5 - failed in uploading zip file ( large zip file )
Anybody know why? please i stuck now , I can't see the pattern here ..... it's to blur ( the PC that failed to upload )
Re: Upload zip file larger then 10 M
Posted: Fri Jun 26, 2009 3:16 am
by VladSun
Take a look at your error logs first ...
failed in uploading zip file
is not descriptive enough

Re: Upload zip file larger then 10 M
Posted: Fri Jun 26, 2009 7:43 am
by wpsd2006
nah thats what i write myself to make it clear
it doesn't return any error that's why i confuse
my system ( you can check in above post )
the process is
post > move the file ( using move upload ) > open the zip > move the file
and i just now tested opera works in win xp
all my ubuntu pc works.
Re: Upload zip file larger then 10 M
Posted: Sun Jun 28, 2009 9:11 pm
by wpsd2006
Ah got it works at last
I don't know whether it's cause by the operating system that the user use or the zip file that they use
probably the OS ...
I found out there is differences in the mime type for zip
1. application/zip
2. application/x-zip-compressed
hmm i don't know what caused this
is there any references for php mime type list