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

Last change on this file since 26461 was 26461, checked in by mistic100, 10 years ago

Update headers to 2014. Happy new year!!

File size: 3.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2014 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24define('PHPWG_ROOT_PATH','../../../');
25define('IN_ADMIN', true);
26
27$_COOKIE['pwg_id'] = $_POST['session_id'];
28
29include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
31include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
32
33check_pwg_token();
34
35ob_start();
36echo '$_FILES'."\n";
37print_r($_FILES);
38echo '$_POST'."\n";
39print_r($_POST);
40echo '$user'."\n";
41print_r($user);
42$tmp = ob_get_contents(); 
43ob_end_clean();
44// error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log");
45
46if ($_FILES['Filedata']['error'] !== UPLOAD_ERR_OK)
47{
48  $error_message = file_upload_error_message($_FILES['Filedata']['error']);
49 
50  add_upload_error(
51    $_POST['upload_id'],
52    sprintf(
53      l10n('Error on file "%s" : %s'),
54      $_FILES['Filedata']['name'],
55      $error_message
56      )
57    );
58
59  echo "File Size Error";
60  exit();
61}
62
63ob_start();
64
65$image_id = add_uploaded_file(
66  $_FILES['Filedata']['tmp_name'],
67  $_FILES['Filedata']['name'],
68  array($_POST['category_id']),
69  $_POST['level']
70  );
71
72$_SESSION['uploads'][ $_POST['upload_id'] ][] = $image_id;
73
74$query = '
75SELECT
76    id,
77    path
78  FROM '.IMAGES_TABLE.'
79  WHERE id = '.$image_id.'
80;';
81$image_infos = pwg_db_fetch_assoc(pwg_query($query));
82
83$thumbnail_url = preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', DerivativeImage::thumb_url($image_infos));
84
85$return = array(
86  'image_id' => $image_id,
87  'category_id' => $_POST['category_id'],
88  'thumbnail_url' => $thumbnail_url,
89  );
90
91$output = ob_get_contents(); 
92ob_end_clean();
93if (!empty($output))
94{
95  add_upload_error($_POST['upload_id'], $output);
96  $return['error_message'] = $output;
97}
98
99echo json_encode($return);
100?>
Note: See TracBrowser for help on using the repository browser.