PHP code example of ifyazilim / dosyayukleme

1. Go to this page and download the library: Download ifyazilim/dosyayukleme library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ifyazilim / dosyayukleme example snippets


// yeni bir dosya yükleme oluşturalım
$dosyaYukleme = new \IfYazilim\DosyaYukleme\DosyaYukleme('resim');

// dosya yüklenmiş mi
if ($dosyaYukleme->count() === 0)
    throw new Exception('Yüklemek için lütfen dosya seçiniz.');

// yükleme sırasın hata oluşmuş ise
if ( ! empty($dosyaYukleme->getHatalar()))
    throw new Exception('Dosya yükleme sırasında hata meydana geldi. Hata açıklaması: ' . implode(', ', $dosyaYukleme->getHatalar()));

// yüklenen dosyayı alalım, eğer birden fazla dosya yüklendiyse, $dosyaYukleme->getIterator()
// kullanılarak içinde dönülebilir.
$dosyaBilgisi = $dosyaYukleme->offsetGet(0);

// yüklenen dosya boyutu en fazla 1M olabilir
if ($dosyaBilgisi->getSize() > 1024 * 1024)
    throw new Exception('Yüklenen dosya en fazla 1M olabilir.');

// yüklenen dosyanın tam adı, ör: merhaba.jpg
echo $dosyaBilgisi->getFilename();

// yüklenen dosyanın uzantısız adı, ör: merhaba
echo $dosyaBilgisi->getBasename();

// yüklenen dosyanın boyutu
echo $dosyaBilgisi->getSize();

// yüklenen dosyanın mimetype'ı
echo $dosyaBilgisi->getMimeType();

// yüklenen dosyanın uzantısı
echo $dosyaBilgisi->getExtension();