9 Maj 2008

Upload plików na serwer

<?php
  if(!empty($_FILES["file_img"]))
  {

    include 'config.php';
    include PATH_INCLUDE . 'function_convert.php';

    $upload_dir = PATH."images/img/";
    $file_tmp  = $_FILES["file_img"]["name"];
    $file_dot  = strrpos($file_tmp, '.');
    $file_name = substr($file_tmp, 0, $file_dot);
    $file_ext  = substr($file_tmp, $file_dot);
   
    $upload_img = $upload_dir . convert_pozycjonowanie($file_name).$file_ext;

    if(move_uploaded_file($_FILES["file_img"]["tmp_name"], $upload_img))
    {
      $file_save = 1;
    }
  }
?>

<FORM METHOD=POST enctype="multipart/form-data">
<INPUT TYPE="file" name="file_img" style="height: 25;"> <input type="submit" name="zapisz" value="zapisz obraz" style="height: 25;"><br> <? if($file_save) echo 'Plik został zapisany.'?>
</FORM>