source: trunk/admin/include/uploadify/uploadify.php @ 6625

Revision 6625, 1.4 KB checked in by plg, 9 years ago (diff)

merge r6624 from branch 2.1 to trunk

bug 1747 fixed: some checks were added to verify the upload will fail for a
too big size or if the upload has failed for a too big size (test on
upload_max_filesize and post_max_size)

Line 
1<?php
2define('PHPWG_ROOT_PATH','../../../');
3define('IN_ADMIN', true);
4
5$_COOKIE['pwg_id'] = $_POST['session_id'];
6
7include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
8include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
9include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
10
11check_pwg_token();
12
13ob_start();
14echo '$_FILES'."\n";
15print_r($_FILES);
16echo '$_POST'."\n";
17print_r($_POST);
18echo '$user'."\n";
19print_r($user);
20$tmp = ob_get_contents(); 
21ob_end_clean();
22// error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log");
23
24if ($_FILES['Filedata']['error'] !== UPLOAD_ERR_OK)
25{
26  $error_message = file_upload_error_message($_FILES['Filedata']['error']);
27 
28  add_upload_error(
29    $_POST['upload_id'],
30    sprintf(
31      l10n('Error on file "%s" : %s'),
32      $_FILES['Filedata']['name'],
33      $error_message
34      )
35    );
36
37  echo "File Size Error";
38  exit();
39}
40
41ob_start();
42
43$image_id = add_uploaded_file(
44  $_FILES['Filedata']['tmp_name'],
45  $_FILES['Filedata']['name'],
46  null,
47  8
48  );
49
50if (!isset($_SESSION['uploads']))
51{
52  $_SESSION['uploads'] = array();
53}
54
55if (!isset($_SESSION['uploads'][ $_POST['upload_id'] ]))
56{
57  $_SESSION['uploads'][ $_POST['upload_id'] ] = array();
58}
59
60array_push(
61  $_SESSION['uploads'][ $_POST['upload_id'] ],
62  $image_id
63  );
64
65$output = ob_get_contents(); 
66ob_end_clean();
67if (!empty($output))
68{
69  add_upload_error($_POST['upload_id'], $output);
70}
71
72echo "1";
73?>
Note: See TracBrowser for help on using the repository browser.