Beispiel #1
0
 /**
  * sayfanın defaul da olması gereken ayarları burada bulunuyor
  */
 private function upload($last_id)
 {
     if (count($_FILES['uploadPic']['name']) > 0) {
         $file_size = '2000000';
         // dosya boyutu
         $allowed_types = 'jpg,gif,png,jpeg';
         // izin verilen uzantılar
         $input_names = array();
         $input_names = $_FILES['uploadPic'];
         $Uploader = new \Lib\Uploader();
         $upload_dir = $this->upload_dir;
         $Uploader->name_format(false, 'st_', '_nc');
         $Uploader->picture_control_value = true;
         // resimin gerçek olup olmadığını kontrol eçindir
         $Uploader->uploader_set($input_names, $upload_dir, $allowed_types, $file_size);
         // çalıştırıcı
         for ($i = 0; $i < count($Uploader->uploaded_files); $i++) {
             $picture = $Uploader->uploaded_files[$i];
             $data = array('photo_post_id' => $last_id, 'photo_filename' => $picture, 'photo_status' => 'open');
             $this->_model->postsPicturesInsert($data);
         }
         if (!$Uploader->uploaded) {
             $ok = \Lib\Tools::message_ver('hata', $Uploader->result_report());
             \Lib\Session::set('message', $ok);
         }
     }
 }
 /**
  * upload örneği
  * http://cms.dev/upload
  */
 public function upload()
 {
     echo '
         <form role="form" method="post" action="" enctype="multipart/form-data" id="posts">
         <input type="file" class="textbox-value" class="btn btn-default btn-file" name="uploadPic[]"></br>
         <input type="submit"  name="gonder"></br>
         </form>
         ';
     if (count($_FILES['uploadPic']['name']) > 0) {
         $file_size = '2000000';
         // dosya boyutu
         $allowed_types = 'jpg,gif,png,jpeg';
         // izin verilen uzantılar
         $input_names = array();
         // gececi aktarılacak yer
         $input_names = $_FILES['uploadPic'];
         // yuklenecek olan input değeri
         $Uploader = new \Lib\Uploader();
         // upload tanıtılır
         $upload_dir = $_SERVER['DOCUMENT_ROOT'] . '/public/resimler';
         // resim yukleneceği yeri gosterir
         $Uploader->name_format(false, 'st_', '_nc');
         // resim onek ve sonek orneğidir //eğer değer true ise resim yuklendiği ismi ile yuklenir
         $Uploader->picture_control_value = true;
         // resimin gerçek olup olmadığını kontrol eçindir
         $Uploader->uploader_set($input_names, $upload_dir, $allowed_types, $file_size);
         // upload a ayarları tanıtılır
         // burada upload yuklenirken veritabanına kayıt etme örneği
         for ($i = 0; $i < count($Uploader->uploaded_files); $i++) {
             $picture = $Uploader->uploaded_files[$i];
             $data = array('photo_post_id' => $last_id, 'photo_filename' => $picture, 'photo_status' => 'open');
             // $this->_model->postsPicturesInsert($data);
         }
         if (!$Uploader->uploaded) {
             echo $Uploader->result_report();
         }
     }
     // <input type="file" class="textbox-value" class="btn btn-default btn-file" name="uploadPic[]"></br>
 }