Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di AvOJaromil
    Registrato dal
    Feb 2006
    residenza
    laddove si stagiona formaggio dentro a dei grossi buchi di tufo
    Messaggi
    549

    problema con script html.it phUploader

    salve,

    ho scaricato lo script in questione ma non riesco a farlo funzionare.

    questo è il codice

    Codice PHP:
    <?
    error_reporting
    (7);
    // Max size PER file in KB, not bytes for simplicity!
    $max_file_size="102400";

    // Max size for all files COMBINED in KB, not bytes for simplicity!
    $max_combined_size="204800";

    //How many file uploads do you want to allow at a time?
    $file_uploads="3";

    //The name of the uploader..
    $websitename="Nome sito";

    // Use random file names? true=yes (recommended), false=use original file name. Random names will help prevent overwritting of existing files!
    $random_name=true;

    // Please keep the array structure.
    $allow_types=array("jpg","gif","png","zip","rar","txt","doc");

    // Path to files folder. If this fails use $fullpath below. With trailing slash
    $folder="./galleria/galleries/";

    // Full url to where files are stored. With Trailing Slash
    $full_url="http://www.YOUR_SITE.com/uploads/";

    // Only use this variable if you wish to use full server paths. Otherwise leave this empty! With trailing slash
    $fullpath="";

    //Use this only if you want to password protect your uploads.
    $password=""

    // MD5 the password.. why not?
    $password_md5=md5($password);

    // If you set a password this is how they get verified!
    If($password) {
        If(
    $_POST['verify_password']==true) {
            If(
    md5($_POST['check_password'])==$password_md5) {
                
    setcookie("phUploader",$password_md5,time()+86400);
                
    sleep(1); //seems to help some people.
                
    header("Location: [url]http://[/url]".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
                exit;
                
            }
        }
    }

    // The password form, if you set a password and the user has not entered it this will show.
    $password_form="";
    If(
    $password) {
        If(
    $_COOKIE['phUploader']!=$password_md5) {
            
    $password_form="<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n";
            
    $password_form.="<table align=\"center\" class=\"table\">\n";
            
    $password_form.="<tr>\n";
            
    $password_form.="<td width=\"100%\" class=\"table_header\" colspan=\"2\">Password Required</td>\n";
            
    $password_form.="</tr>\n";
            
    $password_form.="<tr>\n";
            
    $password_form.="<td width=\"35%\" class=\"table_body\">Enter Password:</td>\n";
            
    $password_form.="<td width=\"65%\" class=\"table_body\"><input type=\"password\" name=\"check_password\" /></td>\n";
            
    $password_form.="</tr>\n";
            
    $password_form.="<td colspan=\"2\" align=\"center\" class=\"table_body\">\n";
            
    $password_form.="<input type=\"hidden\" name=\"verify_password\" value=\"true\">\n";
            
    $password_form.="<input type=\"submit\" value=\" Verify Password \" />\n";
            
    $password_form.="</td>\n";
            
    $password_form.="</tr>\n";
            
    $password_form.="</table>\n";
            
    $password_form.="</form>\n";
        }
    }

    // Function to get the extension a file.
    function get_ext($key) { 
        
    $key=strtolower(substr(strrchr($key"."), 1));
        
    // Cause there the same right?
        
    $key=str_replace("jpeg","jpg",$key);
        return 
    $key;
    }

    $ext_count=count($allow_types);
    $i=0;
    foreach(
    $allow_types AS $extension) {
        
        
    //Gets rid of the last comma for display purpose..
        
        
    If($i <= $ext_count-2) {
            
    $types .="*.".$extension.", ";
        } Else {
            
    $types .="*.".$extension;
        }
        
    $i++;
    }
    unset(
    $i,$ext_count); // why not

    $error="";
    $display_message="";
    $uploaded==false;

    // Dont allow post if $password_form has been populated
    If($_POST['submit']==true AND !$password_form) {

        For(
    $i=0$i <= $file_uploads-1$i++) {
                        
            If(
    $_FILES['file']['name'][$i]) {
                            
                
    $ext=get_ext($_FILES['file']['name'][$i]);
                
    $size=$_FILES['file']['size'][$i];
                
    $max_bytes=$max_file_size*1024;
                
                
    // For random names
                
    If($random_name){
                    
    $file_name[$i]=time()+rand(0,100000).".".$ext;
                } Else {
                    
    $file_name[$i]=$_FILES['file']['name'][$i];
                }
                
                
    //Check if the file type uploaded is a valid file type. 
                            
                
    If(!in_array($ext$allow_types)) {
                                
                    
    $error.= "Invalid extension for your file: ".$_FILES['file']['name'][$i].", only ".$types." are allowed.
    Your file(s) were [b]not[/b] uploaded.
    "
    ;
                                
                    
    //Check the size of each file
                                
                
    } Elseif($size $max_bytes) {
                    
                    
    $error.= "Your file: ".$_FILES['file']['name'][$i]." is to big. Max file size is ".$max_file_size."kb.
    Your file(s) were [b]not[/b] uploaded.
    "
    ;
                    
                    
    // Check if the file already exists on the server..
                
    } Elseif(file_exists($folder.$file_name[$i])) {
                    
                    
    $error.= "The file: ".$_FILES['file']['name'][$i]." exists on this server, please rename your file.
    Your file(s) were [b]not[/b] uploaded.
    "
    ;
                    
                }
                            
            } 
    // If Files
        
        
    // For
        
        //Tally the size of all the files uploaded, check if it's over the ammount.
                    
        
    $total_size=array_sum($_FILES['file']['size']);
                      
        
    $max_combined_bytes=$max_combined_size*1024;
                    
        If(
    $total_size $max_combined_bytes) {
            
    $error.="The max size allowed for all your files combined is ".$max_combined_size."kb
    "
    ;
        }
            
        
        
    // If there was an error take notes here!
        
        
    If($error) {
            
            
    $display_message=$error;
            
        } Else {
            
            
    // No errors so lets do some uploading!
            
            
    For($i=0$i <= $file_uploads-1$i++) {
                    
                If(
    $_FILES['file']['name'][$i]) {
                    
                    If(@
    move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i])) {
                        
    $uploaded=true;
                    } Else {
                        
    $display_message.="Couldn't copy ".$file_name[$i]." to server, please make sure ".$folder." is chmod 777 and the path is correct.\n";
                    }
                }
                    
            } 
    //For
            
        
    // Else
        
    // $_POST AND !$password_form

    ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Language" content="en-us" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title><?php echo $websitename?> - Powered By phUploader</title>

    <?
    If($password_form) {
        
        Echo 
    $password_form;
        
    } Elseif(
    $uploaded==true) {?>

    <table align="center"class="table">

        <tr>
            <td class="table_header" colspan="2">[b]Your file(s) have been uploaded![/b] </td>
        </tr>
        <tr>
        <td class="table_body">
        

    <?
    For($i=0$i <= $file_uploads-1$i++) {
        
        If(
    $_FILES['file']['name'][$i]) {
            
    $file=$i+1;
            
                    Echo(
    "[b]File #".$file.":[/b] <a href=\"".$full_url.$file_name[$i]."\" target=\"_blank\">".$full_url.$file_name[$i]."</a>

    \n"
    );
        }
                    
    }

    ?>


    [url="<?=$_SERVER['PHP_SELF'];?>"]Go Back[/url]


    </td>
    </tr>
    </table>

    <?} Else {?>

    <?If($display_message){?>
        <div align="center" class="error_message"><?=$display_message;?></div>
        

    <?}?>

    <form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="phuploader">
    <table align="center"class="table">

        <tr>
            <td class="table_header" colspan="2">[b]<?=$websitename;?>[/b] </td>
        </tr>
        <tr>
            <td colspan="2" class="upload_info">
                [b]Allowed Types:[/b] <?=$types?>

                [b]Max size per file:[/b] <?=$max_file_size?>kb.

                [b]Max size for all files combined:[/b] <?=$max_combined_size?>kb.

            </td>
        </tr>
        <?For($i=0;$i <= $file_uploads-1;$i++) {?>
            <tr>
                <td class="table_body" width="20%">[b]Select File:[/b] </td>
                <td class="table_body" width="80%"><input type="file" name="file[]" size="30" /></td>
            </tr>
        <?}?>
        <tr>
            <td colspan="2" align="center" class="table_footer">
                <input type="hidden" name="submit" value="true" />
                <input type="submit" value=" Upload File(s) " /> 
                <input type="reset" name="reset" value=" Reset Form " />
            </td>
        </tr>
    </table>
    </form>

    <?}//Please leave this here.. it really dosen't make people hate you or make your site look bad.. ?>
    <table class="table" style="border:0px;" align="center">
        <tr>
            <td><div class="copyright">&copy;[url="http://www.phphq.net?script=phUploader"]phUploader[/url]</div></td>
        </tr>
    </table>
    </body>
    </html>
    come errore mi scrive che la cartella definata in $folders, nel mio caso ./galleria/galleries/ non è configurata per la scrittura quando invece lo è.

    il percorso del file phUploader.php è ROOT/upload
    il percorso della cartella nella quale andranno salvati i file è ROOT/galleria/galleries

    il ./ significa ROOT giusto?

    come posso risolvere?

    mille grazie
    "homer sei tonto come un mulo e due volte più brutto. se uno sconosciuto ti offre un passaggio tu devi accettarlo..."

    www.flickr.com/photos/asciella/
    www.lastfm.it/user/qvaioe/

  2. #2
    ciao,
    sinceramente il codice è lunghissimo quindi gli ho dato solo una sbirciata, ma:
    ./ non significa root bensì il punto indica la cartella corrente.
    Quindi se il file php l'avessi salvato nella cartella /var/www/sito/pippo, e nel file ci fosse scritto ./immagini/ciao.gif, questo codice si riferirebbe all'immagine ciao.gif nel path /var/www/sito/pippo/immagini

    se vuoi riferirti alla cartella root basta mettere il path assoluto, quindi cominciando con lo "/" iniziale.

    Avevo avuto un problema simile con un server winzzoz di aruba che non mi faceva fare upload nella cartella che gli avevo indicato e poi ho scoperto che solo alcune delle cartelle avevano i permessi di scrittura prestabiliti e anche se li modificavo non potevo fare upload, ma dovevo usare solo le cartelle che loro avevano abilitato.

    cmq se devi fare l'upload di qualche immagine puoi fare cosi':
    codice:
    $nome=$_FILES['immagine']['name'];
    $path="./img/".$nome;
    move_uploaded_file($_FILES['immagine']['tmp_name'], $path);
    per esempio passando la variabile immagine tramite form
    ciao ciao
    Quanti programmatori sono necessari per cambiare una lampadina?
    Nessuno, e' un problema hardware.

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.