当前位置: 首页>>代码示例>>PHP>>正文


PHP File::isImage方法代码示例

本文整理汇总了PHP中Idno\Entities\File::isImage方法的典型用法代码示例。如果您正苦于以下问题:PHP File::isImage方法的具体用法?PHP File::isImage怎么用?PHP File::isImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Idno\Entities\File的用法示例。


在下文中一共展示了File::isImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 function post()
 {
     if (\Idno\Core\Idno::site()->session()->isLoggedOn()) {
         if (!empty($_FILES['file']['tmp_name'])) {
             if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
                 exit;
             }
             if (\Idno\Entities\File::isImage($_FILES['file']['tmp_name'])) {
                 $return = false;
                 $file = false;
                 if ($file = \Idno\Entities\File::createThumbnailFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], 1024)) {
                     $return = true;
                     $returnfile = new \stdClass();
                     $returnfile->file = ['_id' => $file];
                     $file = $returnfile;
                 } else {
                     if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true)) {
                         $return = true;
                     }
                 }
                 if ($return) {
                     $t = \Idno\Core\Idno::site()->template();
                     $t->file = $file;
                     echo $t->draw('file/picker/donejs');
                     exit;
                 }
             } else {
                 Idno::site()->session()->addErrorMessage("You can only upload images.");
             }
         }
         $this->forward($_SERVER['HTTP_REDIRECT']);
     }
 }
开发者ID:knownunknowns,项目名称:Known,代码行数:33,代码来源:Picker.php

示例2: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->title = \Idno\Core\site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\site()->currentPage()->getInput('body');
     $this->tags = \Idno\Core\site()->currentPage()->getInput('tags');
     $this->setAccess('PUBLIC');
     if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     // Get photo
     if ($new) {
         if (!empty($_FILES['photo']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name'])) {
                 if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true)) {
                     $this->attachFile($photo);
                     // Now get some smaller thumbnails, with the option to override sizes
                     $sizes = \Idno\Core\site()->events()->dispatch('photo/thumbnail/getsizes', new \Idno\Core\Event(array('sizes' => ['large' => 800, 'medium' => 400, 'small' => 200])));
                     foreach ($sizes->data()['sizes'] as $label => $size) {
                         $filename = $_FILES['photo']['name'];
                         // Experiment: let's not save thumbnails for GIFs, in order to enable animated GIF posting.
                         if ($_FILES['photo']['type'] != 'image/gif') {
                             if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], "{$filename}_{$label}", $size)) {
                                 $varname = "thumbnail_{$label}";
                                 $this->{$varname} = \Idno\Core\site()->config()->url . 'file/' . $thumbnail;
                                 $varname = "thumbnail_{$label}_id";
                                 $this->{$varname} = substr($thumbnail, 0, strpos($thumbnail, '/'));
                             }
                         }
                     }
                 } else {
                     \Idno\Core\site()->session()->addMessage('Image wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\site()->session()->addMessage('This doesn\'t seem to be an image ..');
             }
         } else {
             \Idno\Core\site()->session()->addMessage('We couldn\'t access your image. Please try again.');
             return false;
         }
     }
     if ($this->save()) {
         if ($new) {
             $this->addToFeed();
         }
         // Add it to the Activity Streams feed
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
         return true;
     } else {
         return false;
     }
 }
开发者ID:avewrigley,项目名称:idno,代码行数:62,代码来源:Photo.php

示例3: saveDataFromInput

 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     if ($new) {
         if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
             return false;
         }
     }
     $body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
     if (!empty($_FILES['comic']['tmp_name']) || !empty($this->_id)) {
         $this->body = $body;
         $this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
         $this->description = \Idno\Core\Idno::site()->currentPage()->getInput('description');
         if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
             if ($time = strtotime($time)) {
                 $this->created = $time;
             }
         }
         if (!empty($_FILES['comic']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['comic']['tmp_name'])) {
                 if ($size = getimagesize($_FILES['comic']['tmp_name'])) {
                     $this->width = $size[0];
                     $this->height = $size[1];
                 }
                 if ($comic = \Idno\Entities\File::createFromFile($_FILES['comic']['tmp_name'], $_FILES['comic']['name'], $_FILES['comic']['type'], true)) {
                     $this->attachFile($comic);
                 }
             }
         }
         $this->setAccess(\Idno\Core\Idno::site()->currentPage()->getInput('access', 'PUBLIC'));
         if ($this->save($new)) {
             if ($this->getAccess() == 'PUBLIC') {
                 \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
             }
             return true;
         }
     } else {
         \Idno\Core\Idno::site()->session()->addErrorMessage('You can\'t save an empty comic.');
     }
     return false;
 }
开发者ID:sintoris,项目名称:Known,代码行数:45,代码来源:Comic.php

示例4: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->title = \Idno\Core\site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\site()->currentPage()->getInput('body');
     $this->setAccess('PUBLIC');
     // Get photo
     if ($new) {
         if (!empty($_FILES['photo']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name'])) {
                 if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true)) {
                     $this->attachFile($photo);
                     if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'])) {
                         $this->thumbnail = \Idno\Core\site()->config()->url . 'file/' . $thumbnail;
                         $this->thumbnail_id = substr($thumbnail, 0, strpos($thumbnail, '/'));
                     }
                 } else {
                     \Idno\Core\site()->session()->addMessage('Image wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\site()->session()->addMessage('This doesn\'t seem to be an image ..');
             }
         } else {
             \Idno\Core\site()->session()->addMessage('We couldn\'t access your image. Please try again.');
             return false;
         }
     }
     if ($this->save()) {
         if ($new) {
             $this->addToFeed();
         }
         // Add it to the Activity Streams feed
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
         \Idno\Core\site()->session()->addMessage('Your photo was successfully saved.');
         return true;
     } else {
         return false;
     }
 }
开发者ID:phpsource,项目名称:idno,代码行数:47,代码来源:Photo.php

示例5: saveDataFromInput

 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $body = \Idno\Core\site()->currentPage()->getInput('body');
     if (!empty($_FILES['comic']['tmp_name']) || !empty($this->_id)) {
         $this->body = $body;
         $this->title = \Idno\Core\site()->currentPage()->getInput('title');
         $this->description = \Idno\Core\site()->currentPage()->getInput('description');
         if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
             if ($time = strtotime($time)) {
                 $this->created = $time;
             }
         }
         if (!empty($_FILES['comic']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['comic']['tmp_name'])) {
                 if ($size = getimagesize($_FILES['comic']['tmp_name'])) {
                     $this->width = $size[0];
                     $this->height = $size[1];
                 }
                 if ($comic = \Idno\Entities\File::createFromFile($_FILES['comic']['tmp_name'], $_FILES['comic']['name'], $_FILES['comic']['type'], true)) {
                     $this->attachFile($comic);
                 }
             }
         }
         $this->setAccess('PUBLIC');
         if ($this->save()) {
             if ($new) {
                 // Add it to the Activity Streams feed
                 $this->addToFeed();
             }
             \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
             return true;
         }
     } else {
         \Idno\Core\site()->session()->addMessage('You can\'t save an empty comic.');
     }
     return false;
 }
开发者ID:avewrigley,项目名称:idno,代码行数:42,代码来源:Comic.php

示例6: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     if ($new) {
         if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
             return false;
         }
     }
     $this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
     $this->tags = \Idno\Core\Idno::site()->currentPage()->getInput('tags');
     $access = \Idno\Core\Idno::site()->currentPage()->getInput('access');
     $this->setAccess($access);
     if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     // Get photo
     if ($new) {
         if (!empty($_FILES['photo']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name']) || \Idno\Entities\File::isSVG($_FILES['photo']['tmp_name'], $_FILES['photo']['name'])) {
                 // Extract exif data so we can rotate
                 if (is_callable('exif_read_data') && $_FILES['photo']['type'] == 'image/jpeg') {
                     try {
                         if (function_exists('exif_read_data')) {
                             if ($exif = exif_read_data($_FILES['photo']['tmp_name'])) {
                                 $this->exif = base64_encode(serialize($exif));
                                 // Yes, this is rough, but exif contains binary data that can not be saved in mongo
                             }
                         }
                     } catch (\Exception $e) {
                         $exif = false;
                     }
                 } else {
                     $exif = false;
                 }
                 if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true, true)) {
                     $this->attachFile($photo);
                     // Now get some smaller thumbnails, with the option to override sizes
                     $sizes = \Idno\Core\Idno::site()->events()->dispatch('photo/thumbnail/getsizes', new \Idno\Core\Event(array('sizes' => array('large' => 800, 'medium' => 400, 'small' => 200))));
                     $eventdata = $sizes->data();
                     foreach ($eventdata['sizes'] as $label => $size) {
                         $filename = $_FILES['photo']['name'];
                         // Experiment: let's not save thumbnails for GIFs, in order to enable animated GIF posting.
                         if ($_FILES['photo']['type'] != 'image/gif') {
                             if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], "{$filename}_{$label}", $size, false)) {
                                 $varname = "thumbnail_{$label}";
                                 $this->{$varname} = \Idno\Core\Idno::site()->config()->url . 'file/' . $thumbnail;
                                 $varname = "thumbnail_{$label}_id";
                                 $this->{$varname} = substr($thumbnail, 0, strpos($thumbnail, '/'));
                             }
                         }
                     }
                 } else {
                     \Idno\Core\Idno::site()->session()->addErrorMessage('Image wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\Idno::site()->session()->addErrorMessage('This doesn\'t seem to be an image ..');
             }
         } else {
             \Idno\Core\Idno::site()->session()->addErrorMessage('We couldn\'t access your image. Please try again.');
             return false;
         }
     }
     if ($this->save($new)) {
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
         return true;
     } else {
         return false;
     }
 }
开发者ID:jirkadus,项目名称:Known,代码行数:80,代码来源:Photo.php

示例7: saveDataFromInput

 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $body = \Idno\Core\site()->currentPage()->getInput('body');
     if (!empty($body)) {
         $this->body = $body;
         $this->title = \Idno\Core\site()->currentPage()->getInput('title');
         $this->rating = \Idno\Core\site()->currentPage()->getInput('rating');
         $this->productName = \Idno\Core\site()->currentPage()->getInput('productName');
         $this->productCategory = \Idno\Core\site()->currentPage()->getInput('productCategory');
         $this->productLink = \Idno\Core\site()->currentPage()->getInput('productLink');
         $access = \Idno\Core\site()->currentPage()->getInput('access');
         $this->setAccess($access);
         if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
             if ($time = strtotime($time)) {
                 $this->created = $time;
             }
         }
         if ($new) {
             if (!empty($_FILES['photo']['tmp_name'])) {
                 if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name'])) {
                     // Extract exif data so we can rotate
                     if (is_callable('exif_read_data') && $_FILES['photo']['type'] == 'image/jpeg') {
                         try {
                             if (function_exists('exif_read_data')) {
                                 if ($exif = exif_read_data($_FILES['photo']['tmp_name'])) {
                                     $this->exif = base64_encode(serialize($exif));
                                     // Yes, this is rough, but exif contains binary data that can not be saved in mongo
                                 }
                             }
                         } catch (\Exception $e) {
                             $exif = false;
                         }
                     } else {
                         $exif = false;
                     }
                     if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true, true)) {
                         $this->attachFile($photo);
                         // Now get some smaller thumbnails, with the option to override sizes
                         $sizes = \Idno\Core\site()->events()->dispatch('photo/thumbnail/getsizes', new \Idno\Core\Event(array('sizes' => array('large' => 800, 'medium' => 400, 'small' => 200))));
                         $eventdata = $sizes->data();
                         foreach ($eventdata['sizes'] as $label => $size) {
                             $filename = $_FILES['photo']['name'];
                             if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], "{$filename}_{$label}", $size, false)) {
                                 $varname = "thumbnail_{$label}";
                                 $this->{$varname} = \Idno\Core\site()->config()->url . 'file/' . $thumbnail;
                                 $varname = "thumbnail_{$label}_id";
                                 $this->{$varname} = substr($thumbnail, 0, strpos($thumbnail, '/'));
                             }
                         }
                     }
                 } else {
                     \Idno\Core\site()->session()->addErrorMessage('This doesn\'t seem to be an image ..');
                 }
             }
         }
         if ($this->save($new)) {
             $autosave = new Autosave();
             $autosave->clearContext('review');
             \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
             return true;
         }
     } else {
         \Idno\Core\site()->session()->addErrorMessage('You can\'t save an empty entry.');
     }
     return false;
 }
开发者ID:danito,项目名称:Known-Reviews,代码行数:71,代码来源:Review.php


注:本文中的Idno\Entities\File::isImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。