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


PHP Files::downloadFile方法代码示例

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


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

示例1: newItem

	private function newItem($values) {
		// Local variables
		$files = new Files();
				
		// If an image and the URL was given, we download the image and store it
		if ((@$values['type'] == 'image') && ($url = @$values['url']) && (strlen($url) > 0)) {
			$file_id = $files->downloadFile($url, "download");
			$file = $files->getFile($file_id);
			$key = $file->key;
		}
		
		// If a file was uploaded, we process it
		else if (@$_FILES['file']['tmp_name']) {
			try {
				$file_id = $files->processFile($values['file'], $_FILES['file'], 'Posted file');
				$file = $files->getFile($file_id);
				$key = $file->key;
			}
			catch(Exception $e) {
				$this->addErrorMessage("Unknown error occured");
				return $this->_forward(@$values['type']);
			}
		}
		
		// If an image and file available, resize
		if ((@$values['type'] == 'image') && ($file_id > 0)) {
			$files->fitWidth($file_id, 240,  'small');
			$files->fitWidth($file_id, 500,  'medium');
			$files->fitWidth($file_id, 1024, 'large');
			$files->fitSquare($file_id, 75,  'thumbnails');
			$exif = $files->readExif($file_id);
		}
		
		// Process the date if available		
		$date_type = @$values['date_type'];
		if ($date_type == 'other') {
			$timestamp = Stuffpress_Date::strToTimezone($values['date'], $this->_properties->getProperty('timezone'));
		} 
		else if  ($date_type == 'taken' && $exif) {
			if (isset($exif['DateTimeOriginal'])) {
				$timestamp = Stuffpress_Date::strToTimezone($exif['DateTimeOriginal'], $this->_properties->getProperty('timezone'));
			} else {
				$timestamp = time();
			}
		}
		else {
			$timestamp = time();
		}
		
		// Process the tags if available
		$tags	= @explode(',', $values['tags']);
		
		// Prepare the values for the database
		$data = array();
		$data['published']  = @$timestamp;
		$data['type']	    = @$values['type'];
		$data['file']	    = @$key;
		$data['url']	    = @$values['url'];
		$data['title'] 		= @$values['title'];
		$data['link']  		= @$values['link'];
		$data['embed']  	= @$values['embed'];		
		$data['text']  		= @$values['text'];
		
		// Add or update the item
		$source		= StuffpressModel::forUser($this->_application->user->id);
		$data_table = new Data();
		$item_id 	= $source->addItem($data, $data['published'], $data['type'], $tags, false, false, $data['title']);
		$source_id 	= $source->getID();
		
		// fetch the new item
		$item   = $data_table->getItem($source_id, $item_id);
		
		// Get longitude if provided
		if (!empty($exif['GPSLongitude']) && count($exif['GPSLongitude']) == 3 && !empty($exif['GPSLongitudeRef'])) {
            $longitude = ($exif['GPSLongitudeRef']== 'W' ? '-' : '') . Stuffpress_Exif::exif_gpsconvert( $exif['GPSLongitude'] );
		} else {
			$longitude = @$values['longitude'];	
		}
		
		// Get latitude
        if (!empty($exif['GPSLatitude']) && count($exif['GPSLatitude']) == 3 && !empty($exif['GPSLatitudeRef'])) {
            $latitude = ($exif['GPSLatitudeRef']== 'S' ? '-' : '') . Stuffpress_Exif::exif_gpsconvert( $exif['GPSLatitude'] );
        } else {
 			$latitude  = @$values['latitude'];       	
        }

		// Set it
		if ($latitude && $longitude) {
			$data_table->setLocation($source_id, $item_id, $latitude, $longitude, 0);
		}
		
		// Send notification if twitter post is enabled
		if ($this->_properties->getProperty('twitter_auth') && $values['twitter_notify']) {
			$this->notifyTwitter($item);
		}
		
		// Ping blog search engines
		$this->ping();

		// Redirect to the timeline
//.........这里部分代码省略.........
开发者ID:rjdjohnston,项目名称:core,代码行数:101,代码来源:PostController.php

示例2: Files

    $lResult = $lDB->getResult();
    $lDB->disconnect();


    if (array_key_exists('ID', $lResult) && array_key_exists('DataContainer', $lResult))
    {
      $lID = $lResult['ID'];
      $lVideoID = $lResult['VideoID'];
      $lStatus = $lResult['Status'];
      $lStatusStr = Videos::$Status[$lStatus];
      $lDescr = $lResult['Description'];
      $lDataContainer = $lResult['DataContainer'];


      $lFile = new Files();
      $lFile->downloadFile($gUID, $lDataContainer);

      # Remove file and DB entry
      $lFile->removeFile($gUID, $lDataContainer);

      $lVideos = new Videos();
      $lVideos->removeVideo($lID);
    }
    else
    {
      Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "User with ID $gUID can't download $gVID");
    }
  }

?>
开发者ID:nikunjkacha,项目名称:MPFree,代码行数:30,代码来源:Download.php

示例3: setKeyImage

 private function setKeyImage($story_id, $url)
 {
     $stories = new Stories();
     $files = new Files();
     $file_id = $files->downloadFile($url, "");
     $files->fitSquare($file_id, 50, 'thumbnails');
     $file = $files->getFile($file_id);
     $stories->setThumbnail($story_id, $file->key);
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:9,代码来源:StoryController.php

示例4: _saveFileToDb

 protected function _saveFileToDb($type, $url, $file = null)
 {
     $files = new Files();
     // the audio file should be handled as well
     if (($type == SourceItem::IMAGE_TYPE || $type == SourceItem::AUDIO_TYPE) && strlen($url) > 0) {
         $file_id = $files->downloadFile($url, "download");
         $file = $files->getFile($file_id);
         $key = $file->key;
         // There should be an exception handle here
         // to handle any possible exception from the processes above
     } else {
         if ($file) {
             try {
                 // Process new file
                 $file_id = $files->processFile($file['name'], $file, 'Posted file');
                 $file = $files->getFile($file_id);
                 $key = $file->key;
             } catch (Exception $e) {
                 $this->_buildResponse(Api_BaseController::HTTP_FAILED, 'Failed to process the data');
                 return false;
             }
         } else {
             $this->_buildResponse(Api_BaseController::HTTP_FAILED, 'Failed to process the data');
             return false;
         }
     }
     // If an image and file available, resize
     if ($type == SourceItem::IMAGE_TYPE && $file_id > 0) {
         $this->_ResizeFile($files, $file_id);
         //$exif = $files->readExif($file_id);
     }
     return $key;
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:33,代码来源:BaseController.php


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