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

Revision 11962, 1.9 KB checked in by plg, 8 years ago (diff)

feature 2406 added: if the user wants a new album in the upload form, the album
is created before the start of the upload. The ergonomy is now simpler, the
page is smaller and cleaner.

bug 2373 fixed: now that album is created before upload, uploadify.php gets the
category_id and the level: as soon as it is uploaded (function add_uploaded_file)
the photo gets its final privacy level and is directly associated to the album.
This way, we can have an error on a photo without making orphan all photos of
the same upload group.

feature 2405 added: as soon as a photo is uploaded, its thumbnail is displayed
in the "Uploaded Photos" fieldset, without waiting for other photos to be
uploaded. The latest photos comes first.

I have slighlty changed the integration of colorbox in core. Now we have 2
styles available and by default, we use style2 (overlay in black, title and
control icons outside the popup). It is also used for zooming on bulk manager
in unit mode.

display change: on each uploading photos, instead of showing the transfer
speed, we display the transfer progression in %

bug fixed: the color of the "Start Upload" button was not correct because the
button was not a submit button but a simple type=button.

language: "Upload" button becomes "Start Upload" button.

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();
22error_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  array($_POST['category_id']),
47  $_POST['level']
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$query = '
66SELECT
67    id,
68    path,
69    tn_ext
70  FROM '.IMAGES_TABLE.'
71  WHERE id = '.$image_id.'
72;';
73$image_infos = pwg_db_fetch_assoc(pwg_query($query));
74
75$thumbnail_url = preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', get_thumbnail_url($image_infos));
76
77$return = array(
78  'image_id' => $image_id,
79  'category_id' => $_POST['category_id'],
80  'thumbnail_url' => $thumbnail_url,
81  );
82
83$output = ob_get_contents(); 
84ob_end_clean();
85if (!empty($output))
86{
87  add_upload_error($_POST['upload_id'], $output);
88  $return['error_message'] = $output;
89}
90
91echo json_encode($return);
92?>
Note: See TracBrowser for help on using the repository browser.