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


PHP Media::updateURIOf方法代码示例

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


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

示例1: saveImg

 private function saveImg($html, $folder_name, $user_id, $user_path)
 {
     // go to index.html folder
     chdir($user_path . DS . $folder_name);
     // look for all img elements
     foreach ($html->find('img') as $element) {
         // if picture is local
         if (file_exists($element->src)) {
             // this_presentation_dir/user_id/html -> you are in upload folder
             $filename = ManipulationLib::getFileName($element->src);
             $title = $filename['short_filename'];
             $media = new Media();
             $new_id = $media->saveImagetoDB($this->_user_id, '', $title);
             $new_file_name = $new_id . '.' . $filename['filename_ext'];
             rename($element->src, "../../../media/images/{$this->_user_id}/" . $new_file_name);
             $element->src = "./upload/media/images/{$this->_user_id}/" . $new_file_name;
             $img_size = Util::extractOriginalSizeOf($element->src);
             $media->updateSizeOf($new_id, $img_size);
             $media->updateURIOf($new_id, $element->src);
         }
     }
     chdir("../../..");
 }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:23,代码来源:htmlPresentation.php

示例2: updateURIOf

 function updateURIOf($db_id, $uri)
 {
     $img = new Media();
     $img->updateURIOf($db_id, $uri);
 }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:5,代码来源:pptxPic.php

示例3: upload

 function upload()
 {
     if (isset($_POST['your_link']) && $_POST['your_link'] != '') {
         $postf = split('\\.', $_POST['your_link']);
         $tmp = split('\\/', $_POST['your_link']);
         $user_id = $_SESSION['uid'];
         $media = new Media();
         $name = $tmp[count($tmp) - 1];
         $new_id = $media->saveImagetoDB($user_id, '', $name);
         $folder = './upload/media/images/' . $user_id . '/';
         if (!file_exists($folder)) {
             mkdir($folder);
         }
         $filename = './upload/media/images/' . $user_id . '/' . $new_id . '.' . $postf[count($postf) - 1];
         file_put_contents($filename, file_get_contents($_POST['your_link']));
         $img_size = Util::extractOriginalSizeOf($filename);
         $media->updateSizeOf($new_id, $img_size);
         $media->updateURIOf($new_id, $filename);
         //Form a js-file
         $res = '<script type="text/javascript">';
         $res .= "var data = new Object;";
         $res .= 'data.src="' . $filename . '";';
         $res .= 'data.name="' . $name . '";';
         $res .= 'window.parent.handleResponse(data);';
         $res .= "</script>";
         echo $res;
     }
     if (isset($_FILES['uploaded_img'])) {
         $whitelist = array(".gif", ".jpeg", ".png", ".jpg");
         $data = array();
         $error = true;
         //check the extensions
         foreach ($whitelist as $item) {
             if (preg_match("/{$item}\$/i", $_FILES['uploaded_img']['name'])) {
                 $error = false;
             }
         }
         //if no errors, upload the file
         if (!$error) {
             $folder = './upload/media/images/' . $_SESSION['uid'] . '/';
             if (!file_exists($folder)) {
                 mkdir($folder);
             }
             if (is_uploaded_file($_FILES['uploaded_img']['tmp_name'])) {
                 $name_array = explode('.', basename($_FILES['uploaded_img']['name']));
                 $title = $name_array[0];
                 $user_id = $_SESSION['uid'];
                 $media = new Media();
                 $new_id = $media->saveImagetoDB($user_id, '', $title);
                 $uploadedFile = $folder . $new_id . '.' . $name_array[1];
                 if (move_uploaded_file($_FILES['uploaded_img']['tmp_name'], $uploadedFile)) {
                     $data = $_FILES['uploaded_img'];
                     $data['src'] = $uploadedFile;
                     $img_size = Util::extractOriginalSizeOf($uploadedFile);
                     echo $img_size;
                     $media->updateSizeOf($new_id, $img_size);
                     $media->updateURIOf($new_id, $uploadedFile);
                 } else {
                     $data['errors'] = "An error occured";
                 }
             } else {
                 $data['errors'] = "File was not uploaded";
             }
         } else {
             $data['errors'] = 'The file format is not supported';
         }
         //Form a js-file
         $res = '<script type="text/javascript">';
         $res .= "var data = new Object;";
         foreach ($data as $key => $value) {
             $res .= 'data.' . $key . ' = "' . $value . '";';
         }
         $res .= 'window.parent.handleResponse(data);';
         $res .= "</script>";
         echo $res;
     }
 }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:77,代码来源:ImgController.php


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