Cześć smile.gif

Próbuję zrobic upload obrazków na serwer - duże i miniaturkę.
Zalezy mi na ajaxie czy czyms podobnym - bez przeładowania - pokazuje np wgraną fotke.

Znalazłem bardzo fajny plugin MooTools, ale coś nie działa po odchaczeniu komentarza uploadu. Tak w kazdym razie myślę.

Otóż wszystko ściągnąłem tu:
http://cloud.github.com/downloads/digitara...-photoqueue.zip

opis jest tu:

http://digitarald.de/project/fancyupload/#download

A co zrobiłem?

Wszystko działa jak należy - od strony prezentacji progres bara itp, w końcu to bardziej o to chodzi, ale jest tu też plik script.php, który uploaduje obrazek na serwer i w nim od komentowałem (wrzuciłem cały plik, bo może coś jest istotne, a zaznaczyłem swoim komentarzem - dużymi literami):

  1. <?php
  2. /**
  3.  * Swiff.Uploader Example Backend
  4.  *
  5.  * This file represents a simple logging, validation and output.
  6.  * *
  7.  * WARNING: If you really copy these lines in your backend without
  8.  * any modification, there is something seriously wrong! Drop me a line
  9.  * and I can give you a good rate for fancy and customised installation.
  10.  *
  11.  * No showcase represents 100% an actual real world file handling,
  12.  * you need to move and process the file in your own code!
  13.  * Just like you would do it with other uploaded files, nothing
  14.  * special.
  15.  *
  16.  * @license MIT License
  17.  *
  18.  * @author Harald Kirschner <mail [at] digitarald [dot] de>
  19.  * @copyright Authors
  20.  *
  21.  */
  22.  
  23. /**
  24.  * Only needed if you have a logged in user, see option appendCookieData,
  25.  * which adds session id and other available cookies to the sent data.
  26.  *
  27.  * session_id($_POST['SID']); // whatever your session name is, adapt that!
  28.  * session_start();
  29.  */
  30.  
  31. // Request log
  32.  
  33. /**
  34.  * You don't need to log, this is just for the showcase. Better remove
  35.  * those lines for production since the log contains detailed file
  36.  * information.
  37.  */
  38.  
  39. $result = array();
  40.  
  41. $result['time'] = date('r');
  42. $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6);
  43. $result['agent'] = $_SERVER['HTTP_USER_AGENT'];
  44.  
  45. if (count($_GET)) {
  46. $result['get'] = $_GET;
  47. }
  48. if (count($_POST)) {
  49. $result['post'] = $_POST;
  50. }
  51. if (count($_FILES)) {
  52. $result['files'] = $_FILES;
  53. }
  54.  
  55. // we kill an old file to keep the size small
  56. if (file_exists('script.log') && filesize('script.log') > 102400) {
  57. unlink('script.log');
  58. }
  59.  
  60. $log = @fopen('script.log', 'a');
  61. if ($log) {
  62. fputs($log, print_r($result, true) . "\n---\n");
  63. fclose($log);
  64. }
  65.  
  66.  
  67. // Validation
  68.  
  69. $error = false;
  70.  
  71. if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
  72. $error = 'Invalid Upload';
  73. }
  74.  
  75. /**
  76.  * You would add more validation, checking image type or user rights.
  77.  *
  78.  
  79. if (!$error && $_FILES['Filedata']['size'] > 2 * 1024 * 1024)
  80. {
  81. $error = 'Please upload only files smaller than 2Mb!';
  82. }
  83.  
  84. if (!$error && !($size = @getimagesize($_FILES['Filedata']['tmp_name']) ) )
  85. {
  86. $error = 'Please upload only images, no other files are supported.';
  87. }
  88.  
  89. if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8) ) )
  90. {
  91. $error = 'Please upload only images of type JPEG, GIF or PNG.';
  92. }
  93.  
  94. if (!$error && ($size[0] < 25) || ($size[1] < 25))
  95. {
  96. $error = 'Please upload an image bigger than 25px.';
  97. }
  98. */
  99.  
  100.  
  101. // Processing
  102.  
  103. // TUTAJ SIĘ ZACZYNAŁ KOMENTARZ
  104.  
  105. // Its a demo, you would move or process the file like:
  106.  
  107. move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/' . $_FILES['Filedata']['name']);
  108. $return['src'] = '/uploads/' . $_FILES['Filedata']['name'];
  109. or
  110. $return['link'] = YourImageLibrary::createThumbnail($_FILES['Filedata']['tmp_name']);
  111.  
  112. // TUTAJ KOŃCZYŁ
  113.  
  114. if ($error) {
  115.  
  116. $return = array(
  117. 'status' => '0',
  118. 'error' => $error
  119. );
  120.  
  121. } else {
  122.  
  123. $return = array(
  124. 'status' => '1',
  125. 'name' => $_FILES['Filedata']['name']
  126. );
  127.  
  128. // Our processing, we get a hash value from the file
  129. $return['hash'] = md5_file($_FILES['Filedata']['tmp_name']);
  130.  
  131. // ... and if available, we get image data
  132. $info = @getimagesize($_FILES['Filedata']['tmp_name']);
  133.  
  134. if ($info) {
  135. $return['width'] = $info[0];
  136. $return['height'] = $info[1];
  137. $return['mime'] = $info['mime'];
  138. }
  139.  
  140. }
  141.  
  142.  
  143. // Output
  144.  
  145. /**
  146.  * Again, a demo case. We can switch here, for different showcases
  147.  * between different formats. You can also return plain data, like an URL
  148.  * or whatever you want.
  149.  *
  150.  * The Content-type headers are uncommented, since Flash doesn't care for them
  151.  * anyway. This way also the IFrame-based uploader sees the content.
  152.  */
  153.  
  154. if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') {
  155. // header('Content-type: text/xml');
  156.  
  157. // Really dirty, use DOM and CDATA section!
  158. echo '<response>';
  159. foreach ($return as $key => $value) {
  160. echo "<$key><![CDATA[$value]]></$key>";
  161. }
  162. echo '</response>';
  163. } else {
  164. // header('Content-type: application/json');
  165.  
  166. echo json_encode($return);
  167. }
  168.  
  169. ?>




Bardzo Was prosze o pomoc, bo to fajny bajerek, ale nie mogę sobie poradzić. Pewnie kwestia jakiegos przecinka, nazwy katalogu lub ściezki smile.gif

Będę super zobowiązany smile.gif za pomoc