+
1 8 8

: php

  1. #1
    Arkan       Arkan
    13.10.2006
    bezopasnik.org
    3,112
    ()
    0
    : 0 (: 0).

     php



    <form enctype="multipart/form-data" method="post" action="upload_script.php">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000">
    : <input name="_" type="file">
    <input type="submit" value=" ">
    </form>


    [php]
    <?php
    function doUpload($field_name, $overwrite=false, $uniquename=false)##
    if (!is_array($field_name)) $field_name=Array($field_name);
    #-------- FILE UPLOAD -----------------
    //
    $storage="/data/";

    //
    $flag = (bool) ini_get("safe_mode");
    if ($flag||(!strstr($_SERVER['SERVER_SOFTWARE'], 'win')))##
    if (getmyuid()!=fileowner($storage))##
    die("Safe mode uncompatibililty. Check owner for '".$storage"'");
    }
    }
    // ()
    $allowed=array(
    'jpg',
    'gif',
    'png',
    'pdf',
    'doc',
    'txt',
    'rtf'
    );

    foreach ($field_name as $field_i)##

    // .
    // upload_max_filesize=??M php.ini (2)
    // post_max_size=??M (8)
    $maxsize=61440; // 60K

    //
    $filename=$_FILES[$field_i]['name'];

    //
    $filename=$_FILES[$field_i]['size'];

    //
    $fileext=strtolower(substr(strrchr($filename,"."),1));

    // , PHP !!
    if(!in_array($fileext, $allowed))##
    die(" ");
    }

    //
    if($filesize>$maxsize)##
    die(" ");
    }

    // ,
    // upload_tmp_dir= php.ini
    $tmpfname=$_FILES[$field_i]['tmp_name'])

    // , , .
    $filename = ereg_replace("[^a-z0-9._]", "",
    str_replace(" ", "_",
    str_replace("%20", "_", strtolower($name))));

    if ($filename="")##
    die(" . , '_'!");
    }

    //
    $filepath=$storage;
    if ($uniquename)##
    $filepath=$filepath.time()."_";
    }
    $filepath=$filepath.$filename;

    if (is_uploaded_file($tmpfname) ##

    // $overwrite!=true
    if (!$overwrite)##
    if (file_exists($filepath))##
    die(" <b>".$filename."</b> .
    ");
    }
    }

    move_uploaded_file($tmpfname, $filepath)
    or die(" : ".$filename);
    // FTP , nobody pupkin,
    // FTP ( 0600)
    // 0644 0666 FTP
    @chmod($filepath, 0644);
    }
    }
    }
    #------------- END FILE UPLOAD ----------
    }

    //
    doUpload('_');

    //
    doUpload(Array('_1','_2'));

    //
    doUpload('_', true);

    //
    // , : pic.jpg -> 989181984_pic.jpg
    doUpload('_', false, true);
    ?>[
    /php
    13


    150

  2. #2

  3. #3
    Arkan       Arkan
    13.10.2006
    bezopasnik.org
    3,112
    ()
    0
    : 0 (: 0).




    <form enctype="multipart/form-data" action="/upload.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000000">
    : <input name="userfile" type="file">
    <input type="submit" value=" ">
    </form>


    upload.php
    <?php
    $uploaddir = '/data/UPLOAD/';
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir .
    $_FILES['userfile']['name'])) ##
    print " ";
    } else ##
    print " ";
    }
    ?>


    70

  4. #4
    kisnik       kisnik
    23.09.2006
    22
    ()
    0
    : 0 (: 0).

    . , .

  5. #5
    Kidman       Kidman
    20.12.2008
    3
    ()
    0
    : 0 (: 0).

    . .

  6. #6
    Arkan       Arkan
    13.10.2006
    bezopasnik.org
    3,112
    ()
    0
    : 0 (: 0).



  7. #7
    poligon       poligon
    31.08.2009
    1
    ()
    0
    : 0 (: 0).

    ! , !
    !

    , !
    - 1

    php.ini - !
    ? ?

  8. #8

    AirKite       AirKite
    21.01.2008
    998
    ()
    0
    : 0 (: 0).

    Arkan
    150
    , , upload_max_filesize php.ini
    IT & Creativity
    __________________


    | QuickBinder |