Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Upload

  1. #1

    Upload

    giorno a tutti ..
    ho questo script con un pò di problemi:

    Codice PHP:
     <?php
      
    /*Upload files directory*/
      
    $up_dir $_SERVER['DOCUMENT_ROOT'] . "/Upload/up_files";
      
    /*New name upload file*/
      
    $new_name "1";
      
    /*new_name = "" => new_name = up_file_name*/
      
    $file_name = ($new_name) ? $new_name $_FILES["upfile"]["name"];
      
      @
    is_uploaded_file($_FILES["upfile"]["tmp_name"]);
      @
    move_uploaded_file($_FILES["upfile"]["tmp_name"], "$upload_dir/$new_name");
      
      switch (
    $_FILES["upfile"]["error"])
      {
      case 
    UPLOAD_ERR_OK:
        
    /*throw new exception("Upload terminato correttamente.");*/
          
    break;
      case 
    UPLOAD_ERR_INI_SIZE:
        throw new 
    exception("Il file che si è tentato di caricare è troppo grande!");
          break;
      case 
    UPLOAD_ERR_FORM_SIZE:
        throw new 
    exception("Il file che si è tentato di caricare è troppo grande!");
          break;
      case 
    UPLOAD_ERR_PARTIAL:
        throw new 
    exception("Il file è stato caricato solo parzialmente. Riprova.");
          break;
      case 
    UPLOAD_ERR_NO_FILE:
        throw new 
    exception("Non è stato caricato alcun file!");
          break;
      case 
    UPLOAD_ERR_NO_TMP_DIR:
        throw new 
    exception("Errore interno. &Egrave; stata inviata una segnalazione automatica");
          break;
      case 
    UPLOAD_ERR_CANT_WRITE:
        throw new 
    exception("Tentativo di scrittura del file fallito. Riprova.");
          break;
      default:
        throw new 
    exception("Errore sconosciuto.");
      }

     
    ?>
    1. Penso che il controllo switch non sia ben collegato al resto dello script e non so come poter risolvere il problema.
    2. Nel
    Codice PHP:
         case UPLOAD_ERR_OK:
        
    /*throw new exception("Upload terminato correttamente.");*/
          
    break; 
    non mi accetta 'throw new exception("Upload terminato correttamente.");' riportandomi
    un errore:
    Fatal error: Uncaught exception 'Exception' with message 'Upload terminato correttamente.' in C:\www\Upload\upload.php:37 Stack trace: #0 {main} thrown in C:\www\Upload\upload.php on line 37

    3. Se commento 'throw new exception("Upload terminato correttamente.");' non mi esce
    più nessun errore; però i file non vengono caricati .. perchè??

  2. #2
    tra voi geni del PHP nessuno che possa aiutarmi??

    lo script l' ho diciamo "creato" prendendo da qui:
    http://php.html.it/articoli/leggi/848/upload-con-php/4/

    e qui:
    http://it.php.net/manual/it/features...oad.errors.php

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Da dove hai copiato lo switch? se dal post @ php.net, almeno potevi copiarlo giusto...
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  4. #4
    perchè cos' ho sbagliato? (non riesco a trovare l' errore)
    ho cambiato solo $filearray["error"] perchè penso che faccia riferimento all' array $_FILES .. è sbagliato?

    poi ho inserito: throw new exception("Upload terminato correttamente."); che però ho commentato senò creava problemi.

    comunque adesso ho fatto copia incolla dello switch (prima l' avevo riscritto) .. e non funziona ugualmente

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.