Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: Не работает сессия

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Описание: Не работает сессия
abelousov
Отправлено: 27 Июля, 2012 - 13:34:13
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




Добрый день, впервые столкнулся с такой проблемой и никак не могу ее решить.
На главной странице index.php есть флеш мульти загрузчик изображений, есть два js файла, один с параметрами загрузки и второй обработчик. Также есть upload.php, который загружает каждое изображения на сервер.
Мне необходимо передать переменную с index.php в upload.php.
Пытаюсь через сессию и через куки не работает ни одно ни другое!

index.php
PHP:
скопировать код в буфер обмена
  1.  
  2. $gencode = md5(time());
  3. $_SESSION['gencode']=$gencode;
  4.  


upload.php
PHP:
скопировать код в буфер обмена
  1.  
  2. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3. $uploadDir = 'alboms/'.$_SESSION['gencode'].'/'; //папка для хранения файлов
  4.  
  5. $allowedExt = array('jpg', 'jpeg', 'png', 'gif');
  6. $maxFileSize = 2 * 1024 * 1024; //1 MB
  7.  
  8. //если получен файл
  9. if (isset($_FILES)) {
  10.     //проверяем размер и тип файла
  11.  
  12. ...
  13.    
  14.  


Мне нужно грузить изображения в определенную папку, название которой создается при обработке главной страницы.
Что я делаю не так?
 
 Top
LIME
Отправлено: 27 Июля, 2012 - 14:02:32
Post Id


Активный участник


Покинул форум
Сообщений всего: 10732
Дата рег-ции: Нояб. 2010  


Помог: 322 раз(а)




смотри в инструменте разработчика в браузере
убедись что сессия передается
в браузере ф12 и вкладка сеть
 
 Top
abelousov
Отправлено: 27 Июля, 2012 - 14:07:09
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




да я создавал другие тестовые файлы и там сессия есть.
Я так понимаю что дело в том что файл upload.php подгружает js и поэтому сессия не работает.?!
 
 Top
Toxa
Отправлено: 27 Июля, 2012 - 14:08:41
Post Id



Посетитель


Покинул форум
Сообщений всего: 352
Дата рег-ции: Окт. 2008  


Помог: 8 раз(а)

[+]


js тут явно не при чем.
Вы предоставили недостаточно информации о проблеме.
Поэтому мы не можем на нее указать.


-----
Удобный сервис для хранения файлов
 
 Top
abelousov
Отправлено: 27 Июля, 2012 - 14:19:33
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




Какая информация еще нужна?
я приведу код тогда.

index.php
PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP
  3. $gencode = md5(time());
  4. $_SESSION['gencode']=$gencode;
  5. ?>
  6.  
  7. <!DOCTYPE html>
  8. <html lang="en">
  9.   <head>
  10.    
  11.   </head>
  12.  
  13.   <body>
  14.         <div id="uploadButton"></div>
  15.         <div id="status"></div>
  16.         <div id="images"></div>
  17.           </div>
  18.  
  19.     <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  20.     <script type="text/javascript" src="js/swfupload.js"></script>
  21.     <script type="text/javascript" src="js/plugins/swfupload.queue.js"></script>
  22.     <script type="text/javascript" src="js/main.js"></script>
  23.   </body>
  24. </html>
  25.  


main.js
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. $(document).ready(function() {
  3.    
  4.     function uploadSuccess(file, serverData) {
  5.         $('#images').append($(serverData));
  6.     }
  7.    
  8.     function uploadComplete(file) {
  9.         $('#status').append($('<p>Загрузка ' + file.name + ' завершена</p>'));
  10.     }
  11.    
  12.     function uploadStart(file) {
  13.         $('#status').append($('<p>Начата загрузка файла ' + file.name + '</p>'));
  14.         return true;
  15.     }
  16.    
  17.     function uploadProgress(file, bytesLoaded, bytesTotal) {
  18.         $('#status').append($('<p>Загружено ' + Math.round(bytesLoaded/bytesTotal*100) + '% файла ' + file.name + '</p>'));
  19.     }
  20.  
  21.     function fileDialogComplete(numFilesSelected, numFilesQueued) {
  22.         $('#status').html($('<p>Выбрано ' + numFilesSelected + ' файл(ов), начинаем загрузку</p>'));
  23.         this.startUpload();
  24.     }
  25.  
  26.     var swfu = new SWFUpload(
  27.         {
  28.             upload_url : "upload.php",
  29.             flash_url : "swfupload.swf",
  30.             button_placeholder_id : "uploadButton",
  31.            
  32.             file_size_limit : "2 MB",
  33.             file_types : "*.jpg; *.png; *.jpeg; *.gif",
  34.             file_types_description : "Images",
  35.             file_upload_limit : "0",
  36.             debug: false,
  37.  
  38.             button_image_url: "/instaprints/button.png",
  39.             button_width : 265,
  40.             button_height : 57,
  41.             button_text_left_padding: 30,
  42.             button_text_top_padding: 14,
  43.             button_text : "<span class=\"uploadBtn\">Загрузить фотографии</span>",
  44.             button_text_style : ".uploadBtn { font-size: 19px; font-family: Arial; color:#FFFFFF; }",
  45.            
  46.             file_dialog_complete_handler : fileDialogComplete,
  47.  
  48.             upload_success_handler : uploadSuccess,
  49.             upload_complete_handler : uploadComplete,
  50.             upload_start_handler : uploadStart,
  51.             upload_progress_handler : uploadProgress
  52.         }
  53.     );
  54. });
  55.  
  56.  


swfupload.js
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. var SWFUpload;
  3.  
  4. if (SWFUpload == undefined) {
  5.         SWFUpload = function (settings) {
  6.                 this.initSWFUpload(settings);
  7.         };
  8. }
  9.  
  10. SWFUpload.prototype.initSWFUpload = function (settings) {
  11.         try {
  12.                 this.customSettings = {};       // A container where developers can place their own settings associated with this instance.
  13.                 this.settings = settings;
  14.                 this.eventQueue = [];
  15.                 this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
  16.                 this.movieElement = null;
  17.  
  18.  
  19.                 // Setup global control tracking
  20.                 SWFUpload.instances[this.movieName] = this;
  21.  
  22.                 // Load the settings.  Load the Flash movie.
  23.                 this.initSettings();
  24.                 this.loadFlash();
  25.                 this.displayDebugInfo();
  26.         } catch (ex) {
  27.                 delete SWFUpload.instances[this.movieName];
  28.                 throw ex;
  29.         }
  30. };
  31.  
  32. /* *************** */
  33. /* Static Members  */
  34. /* *************** */
  35. SWFUpload.instances = {};
  36. SWFUpload.movieCount = 0;
  37. SWFUpload.version = "2.2.0 2009-03-25";
  38. SWFUpload.QUEUE_ERROR = {
  39.         QUEUE_LIMIT_EXCEEDED                    : -100,
  40.         FILE_EXCEEDS_SIZE_LIMIT                 : -110,
  41.         ZERO_BYTE_FILE                                  : -120,
  42.         INVALID_FILETYPE                                : -130
  43. };
  44. SWFUpload.UPLOAD_ERROR = {
  45.         HTTP_ERROR                                              : -200,
  46.         MISSING_UPLOAD_URL                      : -210,
  47.         IO_ERROR                                                : -220,
  48.         SECURITY_ERROR                                  : -230,
  49.         UPLOAD_LIMIT_EXCEEDED                   : -240,
  50.         UPLOAD_FAILED                                   : -250,
  51.         SPECIFIED_FILE_ID_NOT_FOUND             : -260,
  52.         FILE_VALIDATION_FAILED                  : -270,
  53.         FILE_CANCELLED                                  : -280,
  54.         UPLOAD_STOPPED                                  : -290
  55. };
  56. SWFUpload.FILE_STATUS = {
  57.         QUEUED           : -1,
  58.         IN_PROGRESS      : -2,
  59.         ERROR            : -3,
  60.         COMPLETE         : -4,
  61.         CANCELLED        : -5
  62. };
  63. SWFUpload.BUTTON_ACTION = {
  64.         SELECT_FILE  : -100,
  65.         SELECT_FILES : -110,
  66.         START_UPLOAD : -120
  67. };
  68. SWFUpload.CURSOR = {
  69.         ARROW : -1,
  70.         HAND : -2
  71. };
  72. SWFUpload.WINDOW_MODE = {
  73.         WINDOW : "window",
  74.         TRANSPARENT : "transparent",
  75.         OPAQUE : "opaque"
  76. };
  77.  
  78. // Private: takes a URL, determines if it is relative and converts to an absolute URL
  79. // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
  80. SWFUpload.completeURL = function(url) {
  81.         if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
  82.                 return url;
  83.         }
  84.        
  85.         var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
  86.        
  87.         var indexSlash = window.location.pathname.lastIndexOf("/");
  88.         if (indexSlash <= 0) {
  89.                 path = "/";
  90.         } else {
  91.                 path = window.location.pathname.substr(0, indexSlash) + "/";
  92.         }
  93.        
  94.         return /*currentURL +*/ path + url;
  95.        
  96. };
  97.  
  98.  
  99. /* ******************** */
  100. /* Instance Members  */
  101. /* ******************** */
  102.  
  103. // Private: initSettings ensures that all the
  104. // settings are set, getting a default value if one was not assigned.
  105. SWFUpload.prototype.initSettings = function () {
  106.         this.ensureDefault = function (settingName, defaultValue) {
  107.                 this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
  108.         };
  109.        
  110.         // Upload backend settings
  111.         this.ensureDefault("upload_url", "");
  112.         this.ensureDefault("preserve_relative_urls", false);
  113.         this.ensureDefault("file_post_name", "Filedata");
  114.         this.ensureDefault("post_params", {});
  115.         this.ensureDefault("use_query_string", false);
  116.         this.ensureDefault("requeue_on_error", false);
  117.         this.ensureDefault("http_success", []);
  118.         this.ensureDefault("assume_success_timeout", 0);
  119.        
  120.         // File Settings
  121.         this.ensureDefault("file_types", "*.*");
  122.         this.ensureDefault("file_types_description", "All Files");
  123.         this.ensureDefault("file_size_limit", 0);       // Default zero means "unlimited"
  124.         this.ensureDefault("file_upload_limit", 0);
  125.         this.ensureDefault("file_queue_limit", 0);
  126.  
  127.         // Flash Settings
  128.         this.ensureDefault("flash_url", "swfupload.swf");
  129.         this.ensureDefault("prevent_swf_caching", true);
  130.        
  131.         // Button Settings
  132.         this.ensureDefault("button_image_url", "");
  133.         this.ensureDefault("button_width", 1);
  134.         this.ensureDefault("button_height", 1);
  135.         this.ensureDefault("button_text", "");
  136.         this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
  137.         this.ensureDefault("button_text_top_padding", 0);
  138.         this.ensureDefault("button_text_left_padding", 0);
  139.         this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
  140.         this.ensureDefault("button_disabled", false);
  141.         this.ensureDefault("button_placeholder_id", "");
  142.         this.ensureDefault("button_placeholder", null);
  143.         this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
  144.         this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
  145.        
  146.         // Debug Settings
  147.         this.ensureDefault("debug", false);
  148.         this.settings.debug_enabled = this.settings.debug;      // Here to maintain v2 API
  149.        
  150.         // Event Handlers
  151.         this.settings.return_upload_start_handler = this.returnUploadStart;
  152.         this.ensureDefault("swfupload_loaded_handler", null);
  153.         this.ensureDefault("file_dialog_start_handler", null);
  154.         this.ensureDefault("file_queued_handler", null);
  155.         this.ensureDefault("file_queue_error_handler", null);
  156.         this.ensureDefault("file_dialog_complete_handler", null);
  157.        
  158.         this.ensureDefault("upload_start_handler", null);
  159.         this.ensureDefault("upload_progress_handler", null);
  160.         this.ensureDefault("upload_error_handler", null);
  161.         this.ensureDefault("upload_success_handler", null);
  162.         this.ensureDefault("upload_complete_handler", null);
  163.        
  164.         this.ensureDefault("debug_handler", this.debugMessage);
  165.  
  166.         this.ensureDefault("custom_settings", {});
  167.  
  168.         // Other settings
  169.         this.customSettings = this.settings.custom_settings;
  170.        
  171.         // Update the flash url if needed
  172.         if (!!this.settings.prevent_swf_caching) {
  173.                 this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
  174.         }
  175.        
  176.         if (!this.settings.preserve_relative_urls) {
  177.                 //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url);     // Don't need to do this one since flash doesn't look at it
  178.                 this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
  179.                 this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
  180.         }
  181.        
  182.         delete this.ensureDefault;
  183. };
  184.  
  185. // Private: loadFlash replaces the button_placeholder element with the flash movie.
  186. SWFUpload.prototype.loadFlash = function () {
  187.         var targetElement, tempParent;
  188.  
  189.         // Make sure an element with the ID we are going to use doesn't already exist
  190.         if (document.getElementById(this.movieName) !== null) {
  191.                 throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
  192.         }
  193.  
  194.         // Get the element where we will be placing the flash movie
  195.         targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
  196.  
  197.         if (targetElement == undefined) {
  198.                 throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
  199.         }
  200.  
  201.         // Append the container and load the flash
  202.         tempParent = document.createElement("div");
  203.         tempParent.innerHTML = this.getFlashHTML();     // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
  204.         targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
  205.  
  206.         // Fix IE Flash/Form bug
  207.         if (window[this.movieName] == undefined) {
  208.                 window[this.movieName] = this.getMovieElement();
  209.         }
  210.        
  211. };
  212.  
  213. // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
  214. SWFUpload.prototype.getFlashHTML = function () {
  215.         // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
  216.         return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
  217.                                 '<param name="wmode" value="', this.settings.button_window_mode, '" />',
  218.                                 '<param name="movie" value="', this.settings.flash_url, '" />',
  219.                                 '<param name="quality" value="high" />',
  220.                                 '<param name="menu" value="false" />',
  221.                                 '<param name="allowScriptAccess" value="always" />',
  222.                                 '<param name="flashvars" value="' + this.getFlashVars() + '" />',
  223.                                 '</object>'].join("");
  224. };
  225.  
  226. // Private: getFlashVars builds the parameter string that will be passed
  227. // to flash in the flashvars param.
  228. SWFUpload.prototype.getFlashVars = function () {
  229.         // Build a string from the post param object
  230.         var paramString = this.buildParamString();
  231.         var httpSuccessString = this.settings.http_success.join(",");
  232.        
  233.         // Build the parameter string
  234.         return ["movieName=", encodeURIComponent(this.movieName),
  235.                         "&uploadURL=", encodeURIComponent(this.settings.upload_url),
  236.                         "&useQueryString=", encodeURIComponent(this.settings.use_query_string),
  237.                         "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
  238.                         "&httpSuccess=", encodeURIComponent(httpSuccessString),
  239.                         "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
  240.                         "&params=", encodeURIComponent(paramString),
  241.                         "&filePostName=", encodeURIComponent(this.settings.file_post_name),
  242.                         "&fileTypes=", encodeURIComponent(this.settings.file_types),
  243.                         "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
  244.                         "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
  245.                         "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
  246.                         "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
  247.                         "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
  248.                         "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
  249.                         "&buttonWidth=", encodeURIComponent(this.settings.button_width),
  250.                         "&buttonHeight=", encodeURIComponent(this.settings.button_height),
  251.                         "&buttonText=", encodeURIComponent(this.settings.button_text),
  252.                         "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
  253.                         "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
  254.                         "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
  255.                         "&buttonAction=", encodeURIComponent(this.settings.button_action),
  256.                         "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
  257.                         "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
  258.                 ].join("");
  259. };
  260.  
  261. // Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
  262. // The element is cached after the first lookup
  263. SWFUpload.prototype.getMovieElement = function () {
  264.         if (this.movieElement == undefined) {
  265.                 this.movieElement = document.getElementById(this.movieName);
  266.         }
  267.  
  268.         if (this.movieElement === null) {
  269.                 throw "Could not find Flash element";
  270.         }
  271.        
  272.         return this.movieElement;
  273. };
  274.  
  275. // Private: buildParamString takes the name/value pairs in the post_params setting object
  276. // and joins them up in to a string formatted "name=value&name=value"
  277. SWFUpload.prototype.buildParamString = function () {
  278.         var postParams = this.settings.post_params;
  279.         var paramStringPairs = [];
  280.  
  281.         if (typeof(postParams) === "object") {
  282.                 for (var name in postParams) {
  283.                         if (postParams.hasOwnProperty(name)) {
  284.                                 paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
  285.                         }
  286.                 }
  287.         }
  288.  
  289.         return paramStringPairs.join("&");
  290. };
  291.  
  292. // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
  293. // all references to the SWF, and other objects so memory is properly freed.
  294. // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
  295. // Credits: Major improvements provided by steffen
  296. SWFUpload.prototype.destroy = function () {
  297.         try {
  298.                 // Make sure Flash is done before we try to remove it
  299.                 this.cancelUpload(null, false);
  300.                
  301.  
  302.                 // Remove the SWFUpload DOM nodes
  303.                 var movieElement = null;
  304.                 movieElement = this.getMovieElement();
  305.                
  306.                 if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
  307.                         // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
  308.                         for (var i in movieElement) {
  309.                                 try {
  310.                                         if (typeof(movieElement[i]) === "function") {
  311.                                                 movieElement[i] = null;
  312.                                         }
  313.                                 } catch (ex1) {}
  314.                         }
  315.  
  316.                         // Remove the Movie Element from the page
  317.                         try {
  318.                                 movieElement.parentNode.removeChild(movieElement);
  319.                         } catch (ex) {}
  320.                 }
  321.                
  322.                 // Remove IE form fix reference
  323.                 window[this.movieName] = null;
  324.  
  325.                 // Destroy other references
  326.                 SWFUpload.instances[this.movieName] = null;
  327.                 delete SWFUpload.instances[this.movieName];
  328.  
  329.                 this.movieElement = null;
  330.                 this.settings = null;
  331.                 this.customSettings = null;
  332.                 this.eventQueue = null;
  333.                 this.movieName = null;
  334.                
  335.                
  336.                 return true;
  337.         } catch (ex2) {
  338.                 return false;
  339.         }
  340. };
  341.  
  342.  
  343. // Public: displayDebugInfo prints out settings and configuration
  344. // information about this SWFUpload instance.
  345. // This function (and any references to it) can be deleted when placing
  346. // SWFUpload in production.
  347. SWFUpload.prototype.displayDebugInfo = function () {
  348.         this.debug(
  349.                 [
  350.                         "---SWFUpload Instance Info---\n",
  351.                         "Version: ", SWFUpload.version, "\n",
  352.                         "Movie Name: ", this.movieName, "\n",
  353.                         "Settings:\n",
  354.                         "\t", "upload_url:               ", this.settings.upload_url, "\n",
  355.                         "\t", "flash_url:                ", this.settings.flash_url, "\n",
  356.                         "\t", "use_query_string:         ", this.settings.use_query_string.toString(), "\n",
  357.                         "\t", "requeue_on_error:         ", this.settings.requeue_on_error.toString(), "\n",
  358.                         "\t", "http_success:             ", this.settings.http_success.join(", "), "\n",
  359.                         "\t", "assume_success_timeout:   ", this.settings.assume_success_timeout, "\n",
  360.                         "\t", "file_post_name:           ", this.settings.file_post_name, "\n",
  361.                         "\t", "post_params:              ", this.settings.post_params.toString(), "\n",
  362.                         "\t", "file_types:               ", this.settings.file_types, "\n",
  363.                         "\t", "file_types_description:   ", this.settings.file_types_description, "\n",
  364.                         "\t", "file_size_limit:          ", this.settings.file_size_limit, "\n",
  365.                         "\t", "file_upload_limit:        ", this.settings.file_upload_limit, "\n",
  366.                         "\t", "file_queue_limit:         ", this.settings.file_queue_limit, "\n",
  367.                         "\t", "debug:                    ", this.settings.debug.toString(), "\n",
  368.  
  369.                         "\t", "prevent_swf_caching:      ", this.settings.prevent_swf_caching.toString(), "\n",
  370.  
  371.                         "\t", "button_placeholder_id:    ", this.settings.button_placeholder_id.toString(), "\n",
  372.                         "\t", "button_placeholder:       ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
  373.                         "\t", "button_image_url:         ", this.settings.button_image_url.toString(), "\n",
  374.                         "\t", "button_width:             ", this.settings.button_width.toString(), "\n",
  375.                         "\t", "button_height:            ", this.settings.button_height.toString(), "\n",
  376.                         "\t", "button_text:              ", this.settings.button_text.toString(), "\n",
  377.                         "\t", "button_text_style:        ", this.settings.button_text_style.toString(), "\n",
  378.                         "\t", "button_text_top_padding:  ", this.settings.button_text_top_padding.toString(), "\n",
  379.                         "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
  380.                         "\t", "button_action:            ", this.settings.button_action.toString(), "\n",
  381.                         "\t", "button_disabled:          ", this.settings.button_disabled.toString(), "\n",
  382.  
  383.                         "\t", "custom_settings:          ", this.settings.custom_settings.toString(), "\n",
  384.                         "Event Handlers:\n",
  385.                         "\t", "swfupload_loaded_handler assigned:  ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
  386.                         "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
  387.                         "\t", "file_queued_handler assigned:       ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
  388.                         "\t", "file_queue_error_handler assigned:  ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
  389.                         "\t", "upload_start_handler assigned:      ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
  390.                         "\t", "upload_progress_handler assigned:   ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
  391.                         "\t", "upload_error_handler assigned:      ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
  392.                         "\t", "upload_success_handler assigned:    ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
  393.                         "\t", "upload_complete_handler assigned:   ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
  394.                         "\t", "debug_handler assigned:             ", (typeof this.settings.debug_handler === "function").toString(), "\n"
  395.                 ].join("")
  396.         );
  397. };
  398.  
  399. /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
  400.         the maintain v2 API compatibility
  401. */
  402. // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
  403. SWFUpload.prototype.addSetting = function (name, value, default_value) {
  404.     if (value == undefined) {
  405.         return (this.settings[name] = default_value);
  406.     } else {
  407.         return (this.settings[name] = value);
  408.         }
  409. };
  410.  
  411. // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
  412. SWFUpload.prototype.getSetting = function (name) {
  413.     if (this.settings[name] != undefined) {
  414.         return this.settings[name];
  415.         }
  416.  
  417.     return "";
  418. };
  419.  
  420.  
  421.  
  422. // Private: callFlash handles function calls made to the Flash element.
  423. // Calls are made with a setTimeout for some functions to work around
  424. // bugs in the ExternalInterface library.
  425. SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
  426.         argumentArray = argumentArray || [];
  427.        
  428.         var movieElement = this.getMovieElement();
  429.         var returnValue, returnString;
  430.  
  431.         // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
  432.         try {
  433.                 returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
  434.                 returnValue = eval(returnString);
  435.         } catch (ex) {
  436.                 throw "Call to " + functionName + " failed";
  437.         }
  438.        
  439.         // Unescape file post param values
  440.         if (returnValue != undefined && typeof returnValue.post === "object") {
  441.                 returnValue = this.unescapeFilePostParams(returnValue);
  442.         }
  443.  
  444.         return returnValue;
  445. };
  446.  
  447. /* *****************************
  448.         -- Flash control methods --
  449.         Your UI should use these
  450.         to operate SWFUpload
  451.    ***************************** */
  452.  
  453. // WARNING: this function does not work in Flash Player 10
  454. // Public: selectFile causes a File Selection Dialog window to appear.  This
  455. // dialog only allows 1 file to be selected.
  456. SWFUpload.prototype.selectFile = function () {
  457.         this.callFlash("SelectFile");
  458. };
  459.  
  460. // WARNING: this function does not work in Flash Player 10
  461. // Public: selectFiles causes a File Selection Dialog window to appear/ This
  462. // dialog allows the user to select any number of files
  463. // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
  464. // If the selection name length is too long the dialog will fail in an unpredictable manner.  There is no work-around
  465. // for this bug.
  466. SWFUpload.prototype.selectFiles = function () {
  467.         this.callFlash("SelectFiles");
  468. };
  469.  
  470.  
  471. // Public: startUpload starts uploading the first file in the queue unless
  472. // the optional parameter 'fileID' specifies the ID
  473. SWFUpload.prototype.startUpload = function (fileID) {
  474.         this.callFlash("StartUpload", [fileID]);
  475. };
  476.  
  477. // Public: cancelUpload cancels any queued file.  The fileID parameter may be the file ID or index.
  478. // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
  479. // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
  480. SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
  481.         if (triggerErrorEvent !== false) {
  482.                 triggerErrorEvent = true;
  483.         }
  484.         this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
  485. };
  486.  
  487. // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
  488. // If nothing is currently uploading then nothing happens.
  489. SWFUpload.prototype.stopUpload = function () {
  490.         this.callFlash("StopUpload");
  491. };
  492.  
  493. /* ************************
  494.  * Settings methods
  495.  *   These methods change the SWFUpload settings.
  496.  *   SWFUpload settings should not be changed directly on the settings object
  497.  *   since many of the settings need to be passed to Flash in order to take
  498.  *   effect.
  499.  * *********************** */
  500.  
  501. // Public: getStats gets the file statistics object.
  502. SWFUpload.prototype.getStats = function () {
  503.         return this.callFlash("GetStats");
  504. };
  505.  
  506. // Public: setStats changes the SWFUpload statistics.  You shouldn't need to
  507. // change the statistics but you can.  Changing the statistics does not
  508. // affect SWFUpload accept for the successful_uploads count which is used
  509. // by the upload_limit setting to determine how many files the user may upload.
  510. SWFUpload.prototype.setStats = function (statsObject) {
  511.         this.callFlash("SetStats", [statsObject]);
  512. };
  513.  
  514. // Public: getFile retrieves a File object by ID or Index.  If the file is
  515. // not found then 'null' is returned.
  516. SWFUpload.prototype.getFile = function (fileID) {
  517.         if (typeof(fileID) === "number") {
  518.                 return this.callFlash("GetFileByIndex", [fileID]);
  519.         } else {
  520.                 return this.callFlash("GetFile", [fileID]);
  521.         }
  522. };
  523.  
  524. // Public: addFileParam sets a name/value pair that will be posted with the
  525. // file specified by the Files ID.  If the name already exists then the
  526. // exiting value will be overwritten.
  527. SWFUpload.prototype.addFileParam = function (fileID, name, value) {
  528.         return this.callFlash("AddFileParam", [fileID, name, value]);
  529. };
  530.  
  531. // Public: removeFileParam removes a previously set (by addFileParam) name/value
  532. // pair from the specified file.
  533. SWFUpload.prototype.removeFileParam = function (fileID, name) {
  534.         this.callFlash("RemoveFileParam", [fileID, name]);
  535. };
  536.  
  537. // Public: setUploadUrl changes the upload_url setting.
  538. SWFUpload.prototype.setUploadURL = function (url) {
  539.         this.settings.upload_url = url.toString();
  540.         this.callFlash("SetUploadURL", [url]);
  541. };
  542.  
  543. // Public: setPostParams changes the post_params setting
  544. SWFUpload.prototype.setPostParams = function (paramsObject) {
  545.         this.settings.post_params = paramsObject;
  546.         this.callFlash("SetPostParams", [paramsObject]);
  547. };
  548.  
  549. // Public: addPostParam adds post name/value pair.  Each name can have only one value.
  550. SWFUpload.prototype.addPostParam = function (name, value) {
  551.         this.settings.post_params[name] = value;
  552.         this.callFlash("SetPostParams", [this.settings.post_params]);
  553. };
  554.  
  555. // Public: removePostParam deletes post name/value pair.
  556. SWFUpload.prototype.removePostParam = function (name) {
  557.         delete this.settings.post_params[name];
  558.         this.callFlash("SetPostParams", [this.settings.post_params]);
  559. };
  560.  
  561. // Public: setFileTypes changes the file_types setting and the file_types_description setting
  562. SWFUpload.prototype.setFileTypes = function (types, description) {
  563.         this.settings.file_types = types;
  564.         this.settings.file_types_description = description;
  565.         this.callFlash("SetFileTypes", [types, description]);
  566. };
  567.  
  568. // Public: setFileSizeLimit changes the file_size_limit setting
  569. SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
  570.         this.settings.file_size_limit = fileSizeLimit;
  571.         this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
  572. };
  573.  
  574. // Public: setFileUploadLimit changes the file_upload_limit setting
  575. SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
  576.         this.settings.file_upload_limit = fileUploadLimit;
  577.         this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
  578. };
  579.  
  580. // Public: setFileQueueLimit changes the file_queue_limit setting
  581. SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
  582.         this.settings.file_queue_limit = fileQueueLimit;
  583.         this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
  584. };
  585.  
  586. // Public: setFilePostName changes the file_post_name setting
  587. SWFUpload.prototype.setFilePostName = function (filePostName) {
  588.         this.settings.file_post_name = filePostName;
  589.         this.callFlash("SetFilePostName", [filePostName]);
  590. };
  591.  
  592. // Public: setUseQueryString changes the use_query_string setting
  593. SWFUpload.prototype.setUseQueryString = function (useQueryString) {
  594.         this.settings.use_query_string = useQueryString;
  595.         this.callFlash("SetUseQueryString", [useQueryString]);
  596. };
  597.  
  598. // Public: setRequeueOnError changes the requeue_on_error setting
  599. SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
  600.         this.settings.requeue_on_error = requeueOnError;
  601.         this.callFlash("SetRequeueOnError", [requeueOnError]);
  602. };
  603.  
  604. // Public: setHTTPSuccess changes the http_success setting
  605. SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
  606.         if (typeof http_status_codes === "string") {
  607.                 http_status_codes = http_status_codes.replace(" ", "").split(",");
  608.         }
  609.        
  610.         this.settings.http_success = http_status_codes;
  611.         this.callFlash("SetHTTPSuccess", [http_status_codes]);
  612. };
  613.  
  614. // Public: setHTTPSuccess changes the http_success setting
  615. SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
  616.         this.settings.assume_success_timeout = timeout_seconds;
  617.         this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
  618. };
  619.  
  620. // Public: setDebugEnabled changes the debug_enabled setting
  621. SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
  622.         this.settings.debug_enabled = debugEnabled;
  623.         this.callFlash("SetDebugEnabled", [debugEnabled]);
  624. };
  625.  
  626. // Public: setButtonImageURL loads a button image sprite
  627. SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
  628.         if (buttonImageURL == undefined) {
  629.                 buttonImageURL = "";
  630.         }
  631.        
  632.         this.settings.button_image_url = buttonImageURL;
  633.         this.callFlash("SetButtonImageURL", [buttonImageURL]);
  634. };
  635.  
  636. // Public: setButtonDimensions resizes the Flash Movie and button
  637. SWFUpload.prototype.setButtonDimensions = function (width, height) {
  638.         this.settings.button_width = width;
  639.         this.settings.button_height = height;
  640.        
  641.         var movie = this.getMovieElement();
  642.         if (movie != undefined) {
  643.                 movie.style.width = width + "px";
  644.                 movie.style.height = height + "px";
  645.         }
  646.        
  647.         this.callFlash("SetButtonDimensions", [width, height]);
  648. };
  649. // Public: setButtonText Changes the text overlaid on the button
  650. SWFUpload.prototype.setButtonText = function (html) {
  651.         this.settings.button_text = html;
  652.         this.callFlash("SetButtonText", [html]);
  653. };
  654. // Public: setButtonTextPadding changes the top and left padding of the text overlay
  655. SWFUpload.prototype.setButtonTextPadding = function (left, top) {
  656.         this.settings.button_text_top_padding = top;
  657.         this.settings.button_text_left_padding = left;
  658.         this.callFlash("SetButtonTextPadding", [left, top]);
  659. };
  660.  
  661. // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
  662. SWFUpload.prototype.setButtonTextStyle = function (css) {
  663.         this.settings.button_text_style = css;
  664.         this.callFlash("SetButtonTextStyle", [css]);
  665. };
  666. // Public: setButtonDisabled disables/enables the button
  667. SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
  668.         this.settings.button_disabled = isDisabled;
  669.         this.callFlash("SetButtonDisabled", [isDisabled]);
  670. };
  671. // Public: setButtonAction sets the action that occurs when the button is clicked
  672. SWFUpload.prototype.setButtonAction = function (buttonAction) {
  673.         this.settings.button_action = buttonAction;
  674.         this.callFlash("SetButtonAction", [buttonAction]);
  675. };
  676.  
  677. // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
  678. SWFUpload.prototype.setButtonCursor = function (cursor) {
  679.         this.settings.button_cursor = cursor;
  680.         this.callFlash("SetButtonCursor", [cursor]);
  681. };
  682.  
  683. /* *******************************
  684.         Flash Event Interfaces
  685.         These functions are used by Flash to trigger the various
  686.         events.
  687.        
  688.         All these functions a Private.
  689.        
  690.         Because the ExternalInterface library is buggy the event calls
  691.         are added to a queue and the queue then executed by a setTimeout.
  692.         This ensures that events are executed in a determinate order and that
  693.         the ExternalInterface bugs are avoided.
  694. ******************************* */
  695.  
  696. SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
  697.         // Warning: Don't call this.debug inside here or you'll create an infinite loop
  698.        
  699.         if (argumentArray == undefined) {
  700.                 argumentArray = [];
  701.         } else if (!(argumentArray instanceof Array)) {
  702.                 argumentArray = [argumentArray];
  703.         }
  704.        
  705.         var self = this;
  706.         if (typeof this.settings[handlerName] === "function") {
  707.                 // Queue the event
  708.                 this.eventQueue.push(function () {
  709.                         this.settings[handlerName].apply(this, argumentArray);
  710.                 });
  711.                
  712.                 // Execute the next queued event
  713.                 setTimeout(function () {
  714.                         self.executeNextEvent();
  715.                 }, 0);
  716.                
  717.         } else if (this.settings[handlerName] !== null) {
  718.                 throw "Event handler " + handlerName + " is unknown or is not a function";
  719.         }
  720. };
  721.  
  722. // Private: Causes the next event in the queue to be executed.  Since events are queued using a setTimeout
  723. // we must queue them in order to garentee that they are executed in order.
  724. SWFUpload.prototype.executeNextEvent = function () {
  725.         // Warning: Don't call this.debug inside here or you'll create an infinite loop
  726.  
  727.         var  f = this.eventQueue ? this.eventQueue.shift() : null;
  728.         if (typeof(f) === "function") {
  729.                 f.apply(this);
  730.         }
  731. };
  732.  
  733. // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
  734. // properties that contain characters that are not valid for JavaScript identifiers. To work around this
  735. // the Flash Component escapes the parameter names and we must unescape again before passing them along.
  736. SWFUpload.prototype.unescapeFilePostParams = function (file) {
  737.         var reg = /[$]([0-9a-f]{4})/i;
  738.         var unescapedPost = {};
  739.         var uk;
  740.  
  741.         if (file != undefined) {
  742.                 for (var k in file.post) {
  743.                         if (file.post.hasOwnProperty(k)) {
  744.                                 uk = k;
  745.                                 var match;
  746.                                 while ((match = reg.exec(uk)) !== null) {
  747.                                         uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
  748.                                 }
  749.                                 unescapedPost[uk] = file.post[k];
  750.                         }
  751.                 }
  752.  
  753.                 file.post = unescapedPost;
  754.         }
  755.  
  756.         return file;
  757. };
  758.  
  759. // Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
  760. SWFUpload.prototype.testExternalInterface = function () {
  761.         try {
  762.                 return this.callFlash("TestExternalInterface");
  763.         } catch (ex) {
  764.                 return false;
  765.         }
  766. };
  767.  
  768. // Private: This event is called by Flash when it has finished loading. Don't modify this.
  769. // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
  770. SWFUpload.prototype.flashReady = function () {
  771.         // Check that the movie element is loaded correctly with its ExternalInterface methods defined
  772.         var movieElement = this.getMovieElement();
  773.  
  774.         if (!movieElement) {
  775.                 this.debug("Flash called back ready but the flash movie can't be found.");
  776.                 return;
  777.         }
  778.  
  779.         this.cleanUp(movieElement);
  780.        
  781.         this.queueEvent("swfupload_loaded_handler");
  782. };
  783.  
  784. // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
  785. // This function is called by Flash each time the ExternalInterface functions are created.
  786. SWFUpload.prototype.cleanUp = function (movieElement) {
  787.         // Pro-actively unhook all the Flash functions
  788.         try {
  789.                 if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
  790.                         this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
  791.                         for (var key in movieElement) {
  792.                                 try {
  793.                                         if (typeof(movieElement[key]) === "function") {
  794.                                                 movieElement[key] = null;
  795.                                         }
  796.                                 } catch (ex) {
  797.                                 }
  798.                         }
  799.                 }
  800.         } catch (ex1) {
  801.        
  802.         }
  803.  
  804.         // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
  805.         // it doesn't display errors.
  806.         window["__flash__removeCallback"] = function (instance, name) {
  807.                 try {
  808.                         if (instance) {
  809.                                 instance[name] = null;
  810.                         }
  811.                 } catch (flashEx) {
  812.                
  813.                 }
  814.         };
  815.  
  816. };
  817.  
  818.  
  819. /* This is a chance to do something before the browse window opens */
  820. SWFUpload.prototype.fileDialogStart = function () {
  821.         this.queueEvent("file_dialog_start_handler");
  822. };
  823.  
  824.  
  825. /* Called when a file is successfully added to the queue. */
  826. SWFUpload.prototype.fileQueued = function (file) {
  827.         file = this.unescapeFilePostParams(file);
  828.         this.queueEvent("file_queued_handler", file);
  829. };
  830.  
  831.  
  832. /* Handle errors that occur when an attempt to queue a file fails. */
  833. SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
  834.         file = this.unescapeFilePostParams(file);
  835.         this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
  836. };
  837.  
  838. /* Called after the file dialog has closed and the selected files have been queued.
  839.         You could call startUpload here if you want the queued files to begin uploading immediately. */
  840. SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
  841.         this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
  842. };
  843.  
  844. SWFUpload.prototype.uploadStart = function (file) {
  845.         file = this.unescapeFilePostParams(file);
  846.         this.queueEvent("return_upload_start_handler", file);
  847. };
  848.  
  849. SWFUpload.prototype.returnUploadStart = function (file) {
  850.         var returnValue;
  851.         if (typeof this.settings.upload_start_handler === "function") {
  852.                 file = this.unescapeFilePostParams(file);
  853.                 returnValue = this.settings.upload_start_handler.call(this, file);
  854.         } else if (this.settings.upload_start_handler != undefined) {
  855.                 throw "upload_start_handler must be a function";
  856.         }
  857.  
  858.         // Convert undefined to true so if nothing is returned from the upload_start_handler it is
  859.         // interpretted as 'true'.
  860.         if (returnValue === undefined) {
  861.                 returnValue = true;
  862.         }
  863.        
  864.         returnValue = !!returnValue;
  865.        
  866.         this.callFlash("ReturnUploadStart", [returnValue]);
  867. };
  868.  
  869.  
  870.  
  871. SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
  872.         file = this.unescapeFilePostParams(file);
  873.         this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
  874. };
  875.  
  876. SWFUpload.prototype.uploadError = function (file, errorCode, message) {
  877.         file = this.unescapeFilePostParams(file);
  878.         this.queueEvent("upload_error_handler", [file, errorCode, message]);
  879. };
  880.  
  881. SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
  882.         file = this.unescapeFilePostParams(file);
  883.         this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
  884. };
  885.  
  886. SWFUpload.prototype.uploadComplete = function (file) {
  887.         file = this.unescapeFilePostParams(file);
  888.         this.queueEvent("upload_complete_handler", file);
  889. };
  890.  
  891. /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
  892.    internal debug console.  You can override this event and have messages written where you want. */
  893. SWFUpload.prototype.debug = function (message) {
  894.         this.queueEvent("debug_handler", message);
  895. };
  896.  
  897.  
  898. /* **********************************
  899.         Debug Console
  900.         The debug console is a self contained, in page location
  901.         for debug message to be sent.  The Debug Console adds
  902.         itself to the body if necessary.
  903.  
  904.         The console is automatically scrolled as messages appear.
  905.        
  906.         If you are using your own debug handler or when you deploy to production and
  907.         have debug disabled you can remove these functions to reduce the file size
  908.         and complexity.
  909. ********************************** */
  910.    
  911. // Private: debugMessage is the default debug_handler.  If you want to print debug messages
  912. // call the debug() function.  When overriding the function your own function should
  913. // check to see if the debug setting is true before outputting debug information.
  914. SWFUpload.prototype.debugMessage = function (message) {
  915.         if (this.settings.debug) {
  916.                 var exceptionMessage, exceptionValues = [];
  917.  
  918.                 // Check for an exception object and print it nicely
  919.                 if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
  920.                         for (var key in message) {
  921.                                 if (message.hasOwnProperty(key)) {
  922.                                         exceptionValues.push(key + ": " + message[key]);
  923.                                 }
  924.                         }
  925.                         exceptionMessage = exceptionValues.join("\n") || "";
  926.                         exceptionValues = exceptionMessage.split("\n");
  927.                         exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
  928.                         SWFUpload.Console.writeLine(exceptionMessage);
  929.                 } else {
  930.                         SWFUpload.Console.writeLine(message);
  931.                 }
  932.         }
  933. };
  934.  
  935. SWFUpload.Console = {};
  936. SWFUpload.Console.writeLine = function (message) {
  937.         var console, documentForm;
  938.  
  939.         try {
  940.                 console = document.getElementById("SWFUpload_Console");
  941.  
  942.                 if (!console) {
  943.                         documentForm = document.createElement("form");
  944.                         document.getElementsByTagName("body")[0].appendChild(documentForm);
  945.  
  946.                         console = document.createElement("textarea");
  947.                         console.id = "SWFUpload_Console";
  948.                         console.style.fontFamily = "monospace";
  949.                         console.setAttribute("wrap", "off");
  950.                         console.wrap = "off";
  951.                         console.style.overflow = "auto";
  952.                         console.style.width = "700px";
  953.                         console.style.height = "350px";
  954.                         console.style.margin = "5px";
  955.                         documentForm.appendChild(console);
  956.                 }
  957.  
  958.                 console.value += message + "\n";
  959.  
  960.                 console.scrollTop = console.scrollHeight - console.clientHeight;
  961.         } catch (ex) {
  962.                 alert("Exception: " + ex.name + " Message: " + ex.message);
  963.         }
  964. };
  965.  


upload.php
PHP:
скопировать код в буфер обмена
  1.  
  2. $uploadDir = 'alboms/'.$_SESSION['gencode'].'/'; //папка для хранения файлов
  3.  
  4. $allowedExt = array('jpg', 'jpeg', 'png', 'gif');
  5. $maxFileSize = 2 * 1024 * 1024; //1 MB
  6.  
  7. //если получен файл
  8. if (isset($_FILES)) {
  9.  
  10. ...
  11.  
  12.  


вот основные файлы, может быть есть другой способ передачи данных в файл upload.php?
но все равно интересно почему сессия в данном случае не работает.
 
 Top
LIME
Отправлено: 27 Июля, 2012 - 14:23:09
Post Id


Активный участник


Покинул форум
Сообщений всего: 10732
Дата рег-ции: Нояб. 2010  


Помог: 322 раз(а)




abelousov пишет:
да я создавал другие тестовые файлы и там сессия есть.
прям молодец
и что это доказывает? что данный документ тоже само собой отправляет сессию?
сам разбирайся
(Добавление)
Toxa пишет:
js тут явно не при чем.
не скажи...он вполне может полезть в куки...хз
 
 Top
caballero
Отправлено: 27 Июля, 2012 - 14:30:42
Post Id


Активный участник


Покинул форум
Сообщений всего: 5998
Дата рег-ции: Сент. 2011  
Откуда: Харьков


Помог: 126 раз(а)




ты ж через флеш дергаешь. а ему твоя сессия пофиг.
передавай явно параметтр в upload.php


-----
Бесплатная система складского учета с открытым кодом https://zippy[dot]com[dot]ua/zstore
 
 Top
abelousov
Отправлено: 27 Июля, 2012 - 14:31:02
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




Цитата:
сам разбирайся

Это конечно верно подмечено)
Я уже пробовал менять хостера, думал может в серваке проблема, поисковики мне тоже не момогли, поэтому я оказался здесь)
(Добавление)
Цитата:
передавай явно параметтр в upload.php

Смысл понимаю, как это сделать нет)

(Отредактировано автором: 27 Июля, 2012 - 14:32:08)

 
 Top
caballero
Отправлено: 27 Июля, 2012 - 14:39:54
Post Id


Активный участник


Покинул форум
Сообщений всего: 5998
Дата рег-ции: Сент. 2011  
Откуда: Харьков


Помог: 126 раз(а)




Цитата:
Смысл понимаю, как это сделать нет)

Да, параметр это очень сложно.

upload_url : "upload.php?parametr=znachenie_parametra",

(Отредактировано автором: 27 Июля, 2012 - 14:40:42)



-----
Бесплатная система складского учета с открытым кодом https://zippy[dot]com[dot]ua/zstore
 
 Top
LIME
Отправлено: 27 Июля, 2012 - 14:44:50
Post Id


Активный участник


Покинул форум
Сообщений всего: 10732
Дата рег-ции: Нояб. 2010  


Помог: 322 раз(а)




caballero то есть флеш сам осуществляет http запрос?
я думал он js для этого дергает
это как это?
 
 Top
caballero
Отправлено: 27 Июля, 2012 - 15:06:41
Post Id


Активный участник


Покинул форум
Сообщений всего: 5998
Дата рег-ции: Сент. 2011  
Откуда: Харьков


Помог: 126 раз(а)




Цитата:
то есть флеш сам осуществляет http запрос?

Разумеется. Судя по всему ему скармливается URL куда запостить данные и он их туда отправляет. Но серверная сессия ему конечно пофиг, то есть он не отправляеьт куки с идентификатором сессии а следовательно PHP сессию восстановить не может.

Сори что нарушил твое распоряжение топикстартеру "разбирайся сам" Радость

(Отредактировано автором: 27 Июля, 2012 - 15:10:58)



-----
Бесплатная система складского учета с открытым кодом https://zippy[dot]com[dot]ua/zstore
 
 Top
LIME
Отправлено: 27 Июля, 2012 - 15:17:05
Post Id


Активный участник


Покинул форум
Сообщений всего: 10732
Дата рег-ции: Нояб. 2010  


Помог: 322 раз(а)




а откуда скармливается?
может есть смысл перевести сессии на гет?
 
 Top
abelousov
Отправлено: 27 Июля, 2012 - 15:17:16
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




Цитата:
PHP сессию восстановить не может

Вот оно значит как..
Цитата:
upload_url : "upload.php?parametr=znachenie_parametra"

Честно говоря ход мыслей у меня был такой же..передать через GET.
Я могу создать невидимый div с переменной <div id="gencode>переменная</div>",
а как мне вписать эту переменную в строку upload_url : "upload.php" ?

gencode = document.getElementById('gencode').innerHTML;
upload_url : "upload.php?id=".gencode,

так?
 
 Top
caballero
Отправлено: 27 Июля, 2012 - 15:23:32
Post Id


Активный участник


Покинул форум
Сообщений всего: 5998
Дата рег-ции: Сент. 2011  
Откуда: Харьков


Помог: 126 раз(а)




Цитата:
а откуда скармливается?


upload_url : "upload.php",

Цитата:
а как мне вписать эту переменную в строку upload_url : "upload.php" ?

формируй этот кусок ява скрипта в PHP файле и тогда можешь вставть обычную PHP переменную


-----
Бесплатная система складского учета с открытым кодом https://zippy[dot]com[dot]ua/zstore
 
 Top
abelousov
Отправлено: 02 Августа, 2012 - 13:39:42
Post Id


Новичок


Покинул форум
Сообщений всего: 6
Дата рег-ции: Июль 2012  


Помог: 0 раз(а)




рабочее решение получилось такое:
в html создаем скрытый див с id
<div id="имя" style="display: none;">переменная</div>

в js пишем:
gencode = document.getElementById('gencode').innerHTML;
upload_url : "upload.php?id="+gencode

всем огромное спасибо!
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« Вопросы новичков »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB