Fix: max file size limit
This commit is contained in:
parent
6c5919b2fd
commit
54d68a12ec
@ -22,7 +22,7 @@
|
|||||||
* \file htdocs/core/class/html.formfile.class.php
|
* \file htdocs/core/class/html.formfile.class.php
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \brief File of class to offer components to list and upload files
|
* \brief File of class to offer components to list and upload files
|
||||||
* \version $Id: html.formfile.class.php,v 1.37 2011/07/03 15:04:18 hregis Exp $
|
* \version $Id: html.formfile.class.php,v 1.38 2011/07/05 09:14:27 hregis Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -739,12 +739,27 @@ class FormFile
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
|
// PHP post_max_size
|
||||||
|
$post_max_size = ini_get('post_max_size');
|
||||||
|
$mul_post_max_size = substr($post_max_size, -1);
|
||||||
|
$mul_post_max_size = ($mul_post_max_size == 'M' ? 1048576 : ($mul_post_max_size == 'K' ? 1024 : ($mul_post_max_size == 'G' ? 1073741824 : 1)));
|
||||||
|
$post_max_size = $mul_post_max_size*(int)$post_max_size;
|
||||||
|
// PHP upload_max_filesize
|
||||||
|
$upload_max_filesize = ini_get('upload_max_filesize');
|
||||||
|
$mul_upload_max_filesize = substr($upload_max_filesize, -1);
|
||||||
|
$mul_upload_max_filesize = ($mul_upload_max_filesize == 'M' ? 1048576 : ($mul_upload_max_filesize == 'K' ? 1024 : ($mul_upload_max_filesize == 'G' ? 1073741824 : 1)));
|
||||||
|
$upload_max_filesize = $mul_upload_max_filesize*(int)$upload_max_filesize;
|
||||||
|
// Max file size
|
||||||
|
$max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
|
||||||
|
|
||||||
print '<script type="text/javascript">
|
print '<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
\'use strict\';
|
\'use strict\';
|
||||||
|
|
||||||
|
var max_file_size = \''.$max_file_size.'\';
|
||||||
|
|
||||||
// Initialize the jQuery File Upload widget:
|
// Initialize the jQuery File Upload widget:
|
||||||
$("#fileupload").fileupload();
|
$("#fileupload").fileupload( { maxFileSize: max_file_size} );
|
||||||
|
|
||||||
// Load existing files:
|
// Load existing files:
|
||||||
$.getJSON($("#fileupload form").prop("action"), { fk_element: "'.$object->id.'", element: "'.$object->element.'"}, function (files) {
|
$.getJSON($("#fileupload form").prop("action"), { fk_element: "'.$object->id.'", element: "'.$object->element.'"}, function (files) {
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* $Id: ajaxfileupload.tpl.php,v 1.4 2011/07/03 14:43:12 hregis Exp $
|
* $Id: ajaxfileupload.tpl.php,v 1.5 2011/07/05 09:14:26 hregis Exp $
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -36,9 +36,9 @@
|
|||||||
</td>
|
</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td class="progress"><div></div></td>
|
<td class="progress"><div></div></td>
|
||||||
<td class="start"><button><?php echo $langs->trans('Start'); ?></button></td>
|
<td align="right" class="start"><button><?php echo $langs->trans('Start'); ?></button></td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<td class="cancel"><button><?php echo $langs->trans('Cancel'); ?></button></td>
|
<td align="right" class="cancel"><button><?php echo $langs->trans('Cancel'); ?></button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user