Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2001
    residenza
    Napoli, Italia
    Messaggi
    1,074

    upload con problemi sul path

    salve,
    ho questo codice per uploadare files:
    Codice PHP:
    <?PHP
    error_reporting
    (7);
    $max_file_size="20484";
    $max_combined_size="20484";
    $file_uploads="1";
    $websitename="phUploader 1.2";
    $random_name=true;
    $allow_types=array("pdf","rtf","txt","doc");
    $full_url="http://www.compasses.ae/uploads/";  
    $fullpath="http://www.compasses.ae/uploads/";
    $password="";

    $password_md5=md5($password);
    If(
    $password) {
        If(
    $_POST['verify_password']==true) {
            If(
    md5($_POST['check_password'])==$password_md5) {
                
    setcookie("phUploader",$password_md5,time()+86400);
                
    sleep(1); 
                
    header("Location: [url]http://[/url]".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
                exit;
            }
        }
    }
    function 
    get_ext($key) { 
        
    $key=strtolower(substr(strrchr($key"."), 1));
        
    $key=str_replace("jpeg","jpg",$key);
        return 
    $key;
    }

    $ext_count=count($allow_types);
    $i=0;
    foreach(
    $allow_types AS $extension) {    
        If(
    $i <= $ext_count-2) {
            
    $types .="*.".$extension.", ";
        } Else {
            
    $types .="*.".$extension;
        }
        
    $i++;
    }
    unset(
    $i,$ext_count);

    $error="";
    $display_message="";
    $uploaded==false;
    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;
                
                If(
    $random_name){
                    
    $file_name[$i]=time()+rand(0,100000).".".$ext;
                } Else {
                    
    $file_name[$i]=$_FILES['file']['name'][$i];
                }
                            
                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.
    "
    ;
                                
                } 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.
    "
    ;
                } 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.
    "
    ;
                    
                }
            }     
        } 

    $total_size=array_sum($_FILES['file']['size']);
                      
        
    $max_combined_bytes=$max_combined_size*2048;
                    
        If(
    $total_size $max_combined_bytes) {
            
    $error.="The max size allowed for all your files combined is ".$max_combined_size."kb
    "
    ;
        }
    If(
    $error) {
            
            
    $display_message=$error;
            
        } Else {
    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";
                    }
                }                
            } 
        } 

    If(
    $password_form) {
            Echo 
    $password_form;
        } Elseif(
    $uploaded==true) {
    echo 
    "Your file(s) have been uploaded!";
    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"
    );
        }        
    }
    } Else { 
    If(
    $display_message) {


    ?>
    (ho omesso la parte html per evitare problemi di visualizzazione)
    la cartella uploads ha i permessi settati su 777, però mi dà questo errore:
    Couldn't copy 1233081602.rtf to server, please make sure is chmod 777 and the path is correct
    Any idea?
    metatad
    graphic & web design

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2001
    residenza
    Napoli, Italia
    Messaggi
    1,074
    no one?
    metatad
    graphic & web design

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.