Questo sito utilizza cookies, anche di terze parti, per mostrare pubblicità e servizi in linea con il tuo account. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP -  swfupload e session
Forum - PHP - swfupload e session

Avatar
jos (Normal User)
Newbie


Messaggi: 20
Iscritto: 18/08/2007

Segnala al moderatore
Postato alle 19:55
Domenica, 24/08/2008
Ciao a tutti, prima di postare ho fatto ricerche sia su google che sul forum senza ottenere risultati quindi espongo a voi il problema... Sto utilizzando swfupload su netsons.org, all'inizio andava benissimo, poi un giorno si e un giorno no perdeva sempre le sessioni, ora non le legge più... praticamente quando faccio invia file, upload.php non legge il contenuto delle sessioni, infatti non riesco ad inserire i file all'interno di una determinata cartella... questo è il codice:

index.php
Codice sorgente - presumibilmente Delphi

  1. <?php
  2.     session_start();
  3. $codedir = time();
  4.                     mkdir("gallery/$codedir", 0700);
  5.                     $_SESSION['mycart'] = $codedir;
  6.     if (count($_FILES)) {
  7.         // Handle degraded form uploads here.  Degraded form uploads are POSTed to index.php.  SWFUpload uploads
  8.         // are POSTed to upload.php
  9.     }
  10.  
  11. ?>
  12. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  13.  
  14. <html xmlns="http://www.w3.org/1999/xhtml" >
  15. <head>
  16. <title>SWFUpload Demos - Multi-Instance Demo</title>
  17. <link href="/css/default.css" rel="stylesheet" type="text/css" />
  18. <script type="text/javascript" src="/swfupload/swfupload.js"></script>
  19. <script type="text/javascript" src="/js/swfupload.graceful_degradation.js"></script>
  20. <script type="text/javascript" src="/js/swfupload.queue.js"></script>
  21. <script type="text/javascript" src="/js/fileprogress.js"></script>
  22. <script type="text/javascript" src="/js/handlers.js"></script>
  23. <script type="text/javascript">
  24.         var upload1, upload2;
  25.  
  26.         window.onload = function() {
  27.             upload1 = new SWFUpload({
  28.                 // Backend Settings
  29.                 upload_url: "/upload.php",    // Relative to the SWF file (or you can use absolute paths)
  30.                 post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
  31.  
  32.                 // File Upload Settings
  33.                 file_size_limit : "102400",    // 100MB
  34.                 file_types : "*.*",
  35.                 file_types_description : "All Files",
  36.                 file_upload_limit : "10",
  37.                 file_queue_limit : "0",
  38.  
  39.                 // Event Handler Settings (all my handlers are in the Handler.js file)
  40.                 file_dialog_start_handler : fileDialogStart,
  41.                 file_queued_handler : fileQueued,
  42.                 file_queue_error_handler : fileQueueError,
  43.                 file_dialog_complete_handler : fileDialogComplete,
  44.                 upload_start_handler : uploadStart,
  45.                 upload_progress_handler : uploadProgress,
  46.                 upload_error_handler : uploadError,
  47.                 upload_success_handler : uploadSuccess,
  48.                 upload_complete_handler : uploadComplete,
  49.  
  50.                 // Flash Settings
  51.                 flash_url : "../swfupload/swfupload_f8.swf",    // Relative to this file (or you can use absolute paths)
  52.                
  53.                 swfupload_element_id : "flashUI1",        // Setting from graceful degradation plugin
  54.                 degraded_element_id : "degradedUI1",    // Setting from graceful degradation plugin
  55.  
  56.                 custom_settings : {
  57.                     progressTarget : "fsUploadProgress1",
  58.                     cancelButtonId : "btnCancel1"
  59.                 },
  60.                
  61.                 // Debug Settings
  62.                 debug: false
  63.             });
  64.  
  65.             upload2 = new SWFUpload({
  66.                 // Backend Settings
  67.                 upload_url: "../multiinstancedemo/upload.php",    // Relative to the SWF file (or you can use absolute paths)
  68.                 post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
  69.  
  70.                 // File Upload Settings
  71.                 file_size_limit : "200",    // 200 kb
  72.                 file_types : "*.jpg;*.gif;*.png",
  73.                 file_types_description : "Image Files",
  74.                 file_upload_limit : "10",
  75.                 file_queue_limit : "2",
  76.  
  77.                 // Event Handler Settings (all my handlers are in the Handler.js file)
  78.                 file_dialog_start_handler : fileDialogStart,
  79.                 file_queued_handler : fileQueued,
  80.                 file_queue_error_handler : fileQueueError,
  81.                 file_dialog_complete_handler : fileDialogComplete,
  82.                 upload_start_handler : uploadStart,
  83.                 upload_progress_handler : uploadProgress,
  84.                 upload_error_handler : uploadError,
  85.                 upload_success_handler : uploadSuccess,
  86.                 upload_complete_handler : uploadComplete,
  87.  
  88.                 // Flash Settings
  89.                 flash_url : "../swfupload/swfupload_f8.swf",    // Relative to this file (or you can use absolute paths)
  90.  
  91.                 swfupload_element_id : "flashUI2",        // Setting from graceful degradation plugin
  92.                 degraded_element_id : "degradedUI2",    // Setting from graceful degradation plugin
  93.  
  94.                 custom_settings : {
  95.                     progressTarget : "fsUploadProgress2",
  96.                     cancelButtonId : "btnCancel2"
  97.                 },
  98.  
  99.                 // Debug Settings
  100.                 debug: false
  101.             });
  102.  
  103.          }
  104.     </script>
  105. </head>
  106. <body>
  107. <div id="header">
  108.     <h1 id="logo"><a href="../">SWFUpload</a></h1>
  109.     <div id="version">v2.1.0 Beta</div>
  110. </div>
  111. <div id="content">
  112.     <h2>Multi-Instance Demo</h2>
  113.     <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
  114.         <p>This page demonstrates how multiple instances of SWFUpload can be loaded on the same page.
  115.             It also demonstrates the use of the graceful degradation plugin and the queue plugin.</p>
  116.         <table>
  117.             <tr valign="top">
  118.                 <td><div id="flashUI1" style="display: none;">
  119.                         <fieldset class="flash" id="fsUploadProgress1">
  120.                         <legend>Large File Upload Site</legend>
  121.                         </fieldset>
  122.                         <div>
  123.                             <input type="button" value="Upload file (Max 100 MB)" onclick="upload1.selectFiles()" style="font-size: 8pt;" />
  124.                             <input id="btnCancel1" type="button" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="font-size: 8pt;" />
  125.                             <br />
  126.                         </div>
  127.                     </div>
  128.                     <div id="degradedUI1">
  129.                         <fieldset>
  130.                         <legend>Large File Upload Site</legend>
  131.                         <input type="file" name="anyfile1" />
  132.                         (Any file, Max 100 MB)<br/>
  133.                         </fieldset>
  134.                         <div>
  135.                             <input type="submit" value="Submit Files" />
  136.                         </div>
  137.                     </div></td>
  138.                 <td><div id="flashUI2" style="display: none;">
  139.                         <fieldset class="flash" id="fsUploadProgress2">
  140.                         <legend>Small File Upload Site</legend>
  141.                         </fieldset>
  142.                         <div>
  143.                             <input type="button" value="Upload file (Max 200KB)" onclick="upload2.selectFiles()" style="font-size: 8pt;" />
  144.                             <input id="btnCancel2" type="button" value="Cancel Uploads" onclick="cancelQueue(upload2);" disabled="disabled" style="font-size: 8pt;" />
  145.                             <br />
  146.                         </div>
  147.                     </div>
  148.                     <div id="degradedUI2">
  149.                         <fieldset>
  150.                         <legend>Small File Upload Site</legend>
  151.                         <input type="file" name="anyfile2" />
  152.                         (Any file, Max 200KB)<br/>
  153.                         </fieldset>
  154.                         <div>
  155.                             <input type="submit" value="Submit Files" />
  156.                         </div>
  157.                     </div></td>
  158.             </tr>
  159.         </table>
  160.     </form>
  161. </div>
  162. </body>
  163. </html>




upload.php
Codice sorgente - presumibilmente Php

  1. <?php
  2.   $my = $_SESSION['mycart'];
  3.   $mydir = "gallery/$my/";
  4.    
  5. if(isset($_FILES['Filedata']) && $_FILES['Filedata']['size']) {
  6.   move_uploaded_file ($_FILES['Filedata']['tmp_name'], $mydir.$_FILES['Filedata']['name']);
  7.   echo "UPLOAD Effettuato";
  8. } else {
  9.    //     echo 'UPLOAD FALLITO '; // I have to return something or SWFUpload won't fire uploadSuccess
  10.    print_r($_FILES);
  11.     }
  12. ?>



In conclusione lo script funziona bene, però l'unico problema è che non leggendo la session invia i file nella cartella gallery/ e non in gallery/$my/... suggerimenti?? please help me... 8-|

PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6108
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 10:46
Mercoledì, 27/08/2008
Penso il problema sia nella configurazione di Php piuttosto che nel codice... Controllato l'eventuale php.ini nella root del tuo spazio web?


Seguimi su Twitter: http://www.twitter.com/pierotofy

Fai quello che ti piace, e fallo bene.
PM Quote