Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Pillola

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    199

    Pillola

    mi ha dato questo errore a seguito del form della pillola per l'upload.
    You don't have permission to access /upload_multiplo/java script:addUpload('file') on this server. Cosa devo fare?

  2. #2

    Re: Pillola

    Originariamente inviato da Mivio84
    mi ha dato questo errore a seguito del form della pillola per l'upload.
    You don't have permission to access /upload_multiplo/java script:addUpload('file') on this server. Cosa devo fare?

    se magari posti il sorgente ti si può dare qualche informazione in più dato che come puoi vedere dall'errore che hai postato tenti di accedere ad una indirizzo errato (in particolare tenti di accedere all'indirizzo assoluto /upload_multiplo che è già si per se sbagliato a occhio e croce e in più java script:addUpload('file') significa che c'è qualcosa di sbagliato anche nel javascript)...

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    199
    CONFIG.PHP
    Codice PHP:
    $dir_upload="Tmp"// DIRECTORY DOVE EFFETTUARE L'UPLOAD
    $chmod_dir=0700// PERMESSI DELLA DIRECTORY
    $debug=0// 1=STAMPA ALCUNE SEMPLICI INFORMAZIONI DI DEBUG, 0=NON STAMPARE
    $sovrascrivi_file=0// 1=SOVRASCRIVI I FILES SE ESISTENTI, 0=NON SOVRASCRIVERE I FILES
    $dim_massima=1500// DIMENSIONE MASSIMA UPLOAD IN KB
    $check_tipi=1//1=CONTROLLA IL TIPO DI FILE, 0=NON CONTROLLARE
    $tipi_permessi=array( //ARRAY PER ALCUNI TIPI DI FILE
        
    "text/plain",
        
    "text/html",
        
    "text/xml",
        
    "image/jpeg",
        
    "image/gif",
        
    "image/png",
        
    "video/mpeg",
        
    "audio/midi",
        
    "application/x-zip-compressed",
        
    "application/vnd.ms-excel",
        
    "application/x-msdos-program",
        
    "application/octet-stream"
    ); 
    INDEX.PHP

    Codice PHP:
    error_reporting(E_ALL);
    require_once(
    "config.php");
    require_once(
    "upload.class.php");

    // ISTANZIA LA CLASSE
    $upload=new upload();
    // SE L'ARRAY $_FILES CONTIENE QUALCOSA ESEGUI IL CODICE PER CARICARE I FILE
    if (count($_FILES) > 0)
        
    $upload->caricafile();
    // ALTRIMENTI MOSTRA IL FORM PER L'UPLOAD
    else
        
    $upload->mostraform(); 
    UPLOAD.CLASS.PHP

    Codice PHP:
    $dir_upload=(substr($dir_upload,-1) != "/" && $dir_upload != "") ? $dir_upload."/" $dir_upload;
    define("DIR_UPLOAD",$dir_upload);
    define("CHMOD_DIR",$chmod_dir);
    define("DEBUG",$debug);
    define("SOVRASCRIVI_FILE",$sovrascrivi_file);
    define("DIM_MASSIMA",$dim_massima*1024);
    define("CHECK_TIPI",$check_tipi);
    define("TIPI_PERMESSI",implode("|",$tipi_permessi));

    class 
    upload {
        function 
    upload(){
        }

        function 
    caricafile(){
            
    //CODICE PER L'UPLOAD CON VARI CONTROLLI
            
    if (count($_FILES) > 0){
                
    $numero_filecount($_FILES['file']['tmp_name']);
                for(
    $i=0;$i<$numero_file;$i++){
                    if(
    $_FILES['file']['size'][$i] == 0){
                        echo 
    "L'UPLOAD DEL FILE [b]{$_FILES['file']['name'][$i]}[/b] NON E' ANDATO A BUON FINE!
    \n"
    ;
                        unset( 
    $_FILES['file']['name'][$i]);
                        unset( 
    $_FILES['file']['type'][$i]);
                        unset( 
    $_FILES['file']['size'][$i]);
                        unset( 
    $_FILES['file']['error'][$i]);
                        unset( 
    $_FILES['file']['tmp_name'][$i]);
                    }
                }
                
    $numero_file=count$_FILES['file']['tmp_name']);
                echo 
    "Hai caricato $numero_file file(s)";
                echo 
    "

    \n"
    ;
                foreach(
    $_FILES['file']['name'] as $chiave=>$valore){
                    if (
    DEBUG == 1){
                        echo 
    "Nome file: [b]".$_FILES['file']['name'][$chiave]."[/b]
    \n"
    ;
                        echo 
    "Tipo file: [b]".$_FILES['file']['type'][$chiave]."[/b]
    \n"
    ;
                        echo 
    "Dimensione: [b]".$_FILES['file']['size'][$chiave]." byte[/b]
    \n"
    ;
                        echo 
    "Nome temporaneo: [b]".$_FILES['file']['tmp_name'][$chiave]."[/b]
    \n"
    ;
                    }
                    if (
    is_uploaded_file$_FILES['file']['tmp_name'][$chiave])){
                        if (
    $_FILES['file']['size'][$chiave] <= DIM_MASSIMA){
                            if(
    CHECK_TIPI == || (CHECK_TIPI == && in_array$_FILES['file']['type'][$chiave], explode("|",TIPI_PERMESSI)))){
                                if(!
    is_dir(DIR_UPLOAD) && DIR_UPLOAD != ""){
                                    if( !@
    mkdir(DIR_UPLOAD,CHMOD_DIR))
                                        die(
    "ERRORE NELLA CREAZIONE DELLA DIRECTORY [b]".DIR_UPLOAD."[/b]");
                                }
                                if(!
    file_exists(DIR_UPLOAD.$_FILES['file']['name'][$chiave]) || SOVRASCRIVI_FILE == 1){
                                    if (@
    move_uploaded_file$_FILES['file']['tmp_name'][$chiave], DIR_UPLOAD.$_FILES['file']['name'][$chiave]))
                                        echo 
    "FILE [b]{$_FILES['file']['name'][$chiave]}[/b] TRASFERITO!";
                                    else
                                        die(
    "ERRORE NEL TRASFERIMENTO DEL FILE [b]".$_FILES['file']['name'][$chiave]."[/b]");
                                } else
                                    echo (
    "IL FILE [b]".$_FILES['file']['name'][$chiave]."[/b] E' ESISTENTE!");
                            } else 
                                echo (
    "IL TIPO DI FILE [b]".$_FILES['file']['type'][$chiave]."[/b] NON E' CONSENTITO!");
                        } else
                            echo (
    "LA DIMENSIONE DEL FILE [b]".$_FILES['file']['type'][$chiave]."[/b] NON E' CONSENTITA!");
                    } else
                        die(
    "ERRORE NEL TRASFERIMENTO DEL FILE [b]".$_FILES['file']['name'][$chiave]."[/b]");
                    echo 
    "<hr />\n";
                }
            }
        }

        function 
    mostraform(){
            
    //FORM PER EFFETTUARE L'UPLOAD
            
    echo "<html>
            <head>
            <script type=\"text/javascript\" src=\"esterno.js\"></script>
            </head>
            <body>
            <form action=\"
    {$_SERVER['PHP_SELF']}\" method=\"POST\" name=\"modulo\" enctype=\"multipart/form-data\">
            <div id=\"attachment\" style=\"display:none\">
                 <input id=\"file\" name=\"file\" type=\"file\" size=\"55\" />
                 <a href=\"#\" onclick=\"java script:removeFile(this.parentNode.parentNode,this.parentNode);\"> Rimuovi</a>
            </div>
            <div id=\"attachments\">
                
    <a id=\"addupload\" href=\"java script:addUpload('file')\">Aggiungi file</a>


                <input name=\"file[]\" type=\"file\" size=\"55\" />
                <span id=\"attachmentmarker\"></span>    
            </div>
            <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\""
    .DIM_MASSIMA."\" />
            <input type=\"submit\" value=\"invia\" />
            </form>

            </body>
            </html>\n"
    ;
        }

    ESTERNO.JS

    var max = 0; // maximum # of attachments allowed
    var currentUploads = 0; // current # of attachment sections on the web page
    var nameDesc = ''; // Name property for the Description Input field
    var nameFile = ''; // Name property for the File Input field
    var scrollPosVert = 0; // stores the current scroll position on the form

    // for some reason when a div is taken out, the form
    // will scroll to the top on both Firefox and IE

    // SCROLL FUNCTIONS
    function saveScrollPos(offset){
    scrollPosVert=(document.all)?document.body.scrollT op:window.pageYOffset-offset;
    }

    function setScrollPos(){
    window.scrollTo(0, scrollPosVert);
    setTimeout('window.scrollTo(0, scrollPosVert)',1);
    }


    // This function adds a new attachment section to the form
    // It is called when the user clicks the "Attach a file" button...
    // It takes three arguments:
    // maxUploads - the maximum number of attachments allowed
    // descFieldName - the field name for the Description Input field
    // fileFieldName - the field name for the File Input field
    function addUpload(fileFieldName){
    nameFile=fileFieldName;
    currentUploads++;
    if (currentUploads>0)
    document.getElementById('addupload').childNodes[0].data='Aggiungi file';
    // First, clone the hidden attachment section
    var newFields = document.getElementById('attachment').cloneNode(tr ue);
    newFields.id = '';
    // Make the new attachments section visible
    newFields.style.display = 'block';
    // loop through tags in the new Attachment section
    // and set ID and NAME properties
    //
    // NOTE: the control names for the Description Input
    // field and the file input field are created
    // by appending the currentUploads variable
    // value to the nameFile and nameDesc values
    // respectively
    //
    // In terms of Xaraya, this means you'll need to name your
    // DD properties will need names like the following:
    // "AttachmentDesc1"
    // "AttachmentFile1"
    // "AttachmentDesc2"
    // "AttachmentFile2"
    // "AttachmentDesc3"
    ???????G?N????g????????????????G?n???????????????? ?????????????????????????dIp????g????????????????? ????????????????????????????????????????…????????? ?????????????????????????????????Z??????????…????? ?????????????????????????????// "AttachmentFile3"
    // et cetera...
    var newField = newFields.childNodes;
    for (var i=0;i<newField.length;i++){
    if (newField[i].name==nameFile){
    newField[i].id=nameFile+currentUploads;
    newField[i].name=nameFile+'[]';
    //newField[i].name=nameFile+currentUploads;
    }
    }
    // Insert our new Attachment section into the Attachments Div
    // on the form...
    var insertHere = document.getElementById('attachmentmarker');
    insertHere.parentNode.insertBefore(newFields,inser tHere);
    }



    // This function removes an attachment from the form
    // and updates the ID and Name properties of all other
    // Attachment sections
    function removeFile(container, item){
    // get the ID number of the upload section to remove
    var tmp = item.getElementsByTagName('input')[0];
    var basefieldname = '';
    basefieldname = nameFile;
    var iRemove=Number(tmp.id.substring(basefieldname.leng th, tmp.id.length));
    // Shift all INPUT field IDs and NAMEs down by one (for fields with a
    // higher ID than the one being removed)
    var x = document.getElementById('attachments').getElements ByTagName('input');
    for (i=0;i<x.length;i++){
    basefieldname=nameFile;
    var iEdit = Number(x[i].id.substring(basefieldname.length, x[i].id.length));
    if (iEdit>iRemove){
    x[i].id=basefieldname+(iEdit-1);
    x[i].name=basefieldname+(iEdit-1);
    }
    }

    // Run through all the DropCap divs (the number to the right of the attachment
    // section) and update that number...
    x=document.getElementById('attachments').getElemen tsByTagName('div');
    for (i=0;i<x.length;i++){
    // Verify this is actually the "dropcap" div
    if (x[i].id.substring(0, String('dropcap').length)=='dropcap'){
    ID = Number(x[i].id.substring(String('dropcap').length, x[i].id.length));
    // check to see if current attachment had a higher ID than the one we're
    // removing (and thus needs to have its ID dropped)
    if (ID>iRemove){
    x[i].id='dropcap'+(ID-1);
    x[i].childNodes[0].data=(ID-1);
    }
    }
    }

    currentUploads--;
    saveScrol ???????G?????g?lPos(0);
    container.removeChild(item);
    setScrollPos();
    document.getElementById('addupload').style.visibil ity='visible';
    if (currentUploads==0)
    document.getElementById('addupload').childNodes[0].data='Aggiungi file';
    }




    questo è tutto il codice, adesso siete in grado di trovare l'errore?

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 © 2025 vBulletin Solutions, Inc. All rights reserved.