本文整理汇总了PHP中File::getFullPath方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getFullPath方法的具体用法?PHP File::getFullPath怎么用?PHP File::getFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::getFullPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception('Unable to open file: ' . $f->getFilename());
}
$uploader = UploadBuilder::newInstance()->setClient($this->client)->setSource($f->getFullPath())->setBucket($this->containerName)->setKey($this->getRelativeLinkFor($f))->build();
try {
$uploader->upload();
} catch (MultipartUploadException $e) {
$uploader->abort();
}
}
示例2: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception('Unable to open file: ' . $f->getFilename());
}
$uploader = new MultipartUploader($this->client, $f->getFullPath(), array('bucket' => $this->containerName, 'key' => $this->getRelativeLinkFor($f)));
try {
$uploader->upload();
} catch (MultipartUploadException $e) {
// warning: below exception gets silently swallowed!
error_log('S3Bucket: failed to put file: ' . $e->getPrevious()->getMessage());
throw new Exception('S3Bucket: failed to put file: ' . $e->getPrevious()->getMessage(), 0, $e);
}
}
示例3: decryptFile
/**
* @param \File $file
* @param null|Key $key
* @return bool|\File
* @throws InvalidInput
* @throws CryptoException
*/
public function decryptFile($file, $key = null)
{
$key = $this->getKey($key);
$decryptedFilename = str_replace('.enc', '', $file->getFullPath());
try {
File::decryptFile($file->getFullPath(), $decryptedFilename, $key);
unlink($file->getFullPath());
$file->Filename = str_replace('.enc', '', $file->Filename);
$file->Name = str_replace('.enc', '', $file->Name);
$file->write();
return $file;
} catch (Exception $e) {
SS_Log::log(sprintf('Decryption exception while parsing "%s": %s', $file->Name, $e->getMessage()), SS_Log::ERR);
return false;
}
}
示例4: onAfterLoad
/**
* update the uploaded image with an optimized kraked file
* @param File $file
* @param Array $tmpFile
* @TODO need to remake cropped images
*/
public function onAfterLoad($file, $tmpFile)
{
$siteConfig = SiteConfig::current_site_config();
if (!$siteConfig->DisableKraken && $file->appCategory() === 'image') {
$krakenService = new KrakenService();
$data = $krakenService->optimizeImage($file->getFullPath());
//check if optimization was success
if ($data['success']) {
//attempt to download the kraked file
$krakedFile = $krakenService->getOptimizedImage($data['kraked_url']);
//update the uploaded file
file_put_contents($file->getFullPath(), $krakedFile);
$file->Kraked = true;
$file->write();
}
}
}
示例5: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception("Unable to open file: " . $f->getFilename());
}
$headers = array();
if (!empty($this->config[self::FORCE_DL])) {
$headers['Content-Disposition'] = 'attachment; filename=' . ($f->hasMethod('getFriendlyName') ? $f->getFriendlyName() : $f->Name);
}
$this->getContainer()->uploadObject($this->getRelativeLinkFor($f), $fp, $headers);
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-cloudassets-rackspace,代码行数:16,代码来源:RackspaceBucket.php
示例6: rename
function rename($new_name)
{
if (strstr($new_name, "/") !== false) {
throw new InvalidParameterException("Il nome contiene caratteri non ammessi ( / )!!");
}
$this_dir = $this->getDirectory();
$target_path = $this_dir->getPath() . "/" . $new_name;
$target_file = new File($target_path);
if ($target_file->exists()) {
return false;
}
return rename($this->__full_path, $target_file->getFullPath());
}
示例7: extract
static function extract($f, $dir)
{
$reader = $f->openReader();
$binarydata = $reader->read(3);
$data = unpack("a3", $binarydata);
if ($data[1] !== self::FF_ARCHIVE_HEADER) {
throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
}
$binarydata = $reader->read(2 + 2 + 2);
$data = unpack("v3", $binarydata);
if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
}
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$num_entries = $data[1];
$i = 0;
while ($i < $num_entries) {
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$entry_type = $data[1];
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$path_length = $data[1];
$binarydata = $reader->read($path_length);
$data = unpack("a*", $binarydata);
$path = $data[1];
if ($entry_type === self::ENTRY_TYPE_DIR) {
$d = $dir->newSubdir($path);
$d->touch();
}
if ($entry_type === self::ENTRY_TYPE_FILE) {
$binarydata = $reader->read(4);
$data = unpack("V", $binarydata);
$num_bytes = $data[1];
$compressed_file_data = $reader->read($num_bytes);
$uncompressed_file_data = gzuncompress($compressed_file_data);
$f = new File($dir->getPath() . $path);
$writer = $f->openWriter();
$writer->write($uncompressed_file_data);
$writer->close();
$sha1_checksum = $reader->read(20);
if (strcmp($sha1_checksum, sha1_file($f->getFullPath(), true)) !== 0) {
throw new InvalidDataException("La somma sha1 non corrisponde per il file : " . $f->getPath());
}
}
$i++;
}
$reader->close();
}
示例8: expandArchive
public static function expandArchive($zip_file, $target_folder)
{
$zip_archive = new ZipArchive();
if ($zip_file instanceof File) {
$real_zip_file = $zip_file;
} else {
$real_zip_file = new File($zip_file);
}
if ($target_folder instanceof Dir) {
$target_dir = $target_folder;
} else {
$target_dir = new Dir($target_folder);
}
$zip_archive->open($real_zip_file->getFullPath());
$zip_archive->extractTo($target_dir->getFullPath());
$zip_archive->close();
}
示例9: run
public function run(File $file)
{
$fpath = $file->getFullPath();
$fpathlen = strlen($fpath);
$res = new Tool_Result();
$cmd = 'xmllint --noout ' . escapeshellarg($fpath) . ' 2>&1';
exec($cmd, $output, $retval);
if ($retval == 0) {
$res->annotations['general'][] = new Tool_Result_Line('XML is well-formed', 'ok');
return $res;
}
for ($i = 0; $i < count($output); $i += 3) {
$line = $output[$i];
if (substr($line, 0, $fpathlen) != $fpath) {
throw new Exception('xmllint does not behave as expected: ' . $line);
}
list($linenum, $msg) = explode(':', substr($line, $fpathlen + 1), 2);
$res->annotations[$linenum][] = new Tool_Result_Line($msg, 'error');
}
$res->annotations['general'][] = new Tool_Result_Line('XML is not well-formed', 'error');
return $res;
}
示例10: run
public function run(File $file)
{
$fpath = $file->getFullPath();
$fpathlen = strlen($fpath);
$res = new Tool_Result();
$cmd = 'php -l ' . escapeshellarg($fpath) . ' 2>&1';
exec($cmd, $output, $retval);
if ($retval == 0) {
$res->annotations['general'][] = new Tool_Result_Line('No syntax errors detected', 'ok');
return $res;
}
$regex = '#^(.+) in ' . preg_quote($fpath) . ' on line ([0-9]+)$#';
for ($i = 0; $i < count($output) - 1; $i++) {
$line = $output[$i];
if (!preg_match($regex, trim($line), $matches)) {
throw new Exception('"php -l" does not behave as expected: ' . $line);
}
$msg = $matches[1];
$linenum = $matches[2];
$res->annotations[$linenum][] = new Tool_Result_Line($msg, 'error');
}
$res->annotations['general'][] = new Tool_Result_Line('PHP code has syntax errors', 'error');
return $res;
}
示例11: moveTo
/**
*
* Moves this element and all its content to the specified target directory.
*
* @param \Mbcraft\Piol\Dir|string $target_dir The target directory as string path or Dir instance.
* @param string $new_name The optional new full name of the moved element.
* @return boolean true if this operation was succesfull, false otherwise.
*
* @api
*/
public function moveTo($target_dir, $new_name = null)
{
$target = Dir::asDir($target_dir);
if ($new_name != null) {
$name = $new_name;
} else {
if ($this->isDir()) {
$name = $this->getName();
} else {
$name = $this->getFullName();
}
}
if ($this->isDir()) {
$dest = new Dir($target->getPath() . DS . $name);
} else {
$dest = new File($target->getPath() . DS . $name);
}
$target->touch();
return rename($this->getFullPath(), $dest->getFullPath());
}
示例12: sendFileToBrowser
/**
*
* @param File $file
* @return void
*/
public function sendFileToBrowser($file)
{
$path = $file->getFullPath();
if (SapphireTest::is_running_test()) {
return file_get_contents($path);
}
$basename = basename($path);
$length = $file->getAbsoluteSize();
$type = HTTP::get_mime_type($file->getRelativePath());
//handling time limitation
if ($threshold = $this->config()->bandwidth_threshold) {
increase_time_limit_to((int) ($length / $threshold));
} else {
increase_time_limit_to();
}
// send header
header('Content-Description: File Transfer');
/*
* allow inline 'save as' popup, double quotation is present to prevent browser (eg. Firefox) from handling
* wrongly a file with a name with whitespace, through a file in SilverStripe should not contain any whitespace
* if the file is uploaded through SS interface
* http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download
*/
header('Content-Type: ' . $type);
header('Content-Disposition: inline; filename=' . $basename);
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $length);
/**
* issue fixes for IE6,7,8 when downloading a file over HTTPS (http://support.microsoft.com/kb/812935)
* http://www.dotvoid.com/2009/10/problem-with-downloading-files-with-internet-explorer-over-https/
*/
if (Director::is_https()) {
header('Pragma: ');
}
header('Expires: 0');
header('Cache-Control: must-revalidate');
/**
* unload the php session file
* see http://konrness.com/php5/how-to-prevent-blocking-php-requests
*/
session_write_close();
// if output buffering is active, we clear it to prevent the script from trying to to allocate memory for entire file.
while (ob_get_level() > 0) {
ob_end_clean();
}
flush();
readfile($path);
exit(0);
}
开发者ID:helpfulrobot,项目名称:deviateltd-silverstripe-advancedassets,代码行数:54,代码来源:SecuredFileController.php
示例13: sendFile
/**
*
* COPIED CODE!!!!!
*
* This is copied from here:
* https://github.com/silverstripe-labs/silverstripe-secureassets/blob/master/code/SecureFileController.php
*
* @param File $file
*/
protected function sendFile($file)
{
$path = $file->getFullPath();
if (SapphireTest::is_running_test()) {
return file_get_contents($path);
}
header('Content-Description: File Transfer');
// Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)
header('Content-Disposition: inline; filename="' . basename($path) . '"');
header('Content-Length: ' . $file->getAbsoluteSize());
header('Content-Type: ' . HTTP::get_mime_type($file->getRelativePath()));
header('Content-Transfer-Encoding: binary');
// Fixes IE6,7,8 file downloads over HTTPS bug (http://support.microsoft.com/kb/812935)
header('Pragma: ');
if ($this->config()->min_download_bandwidth) {
// Allow the download to last long enough to allow full download with min_download_bandwidth connection.
increase_time_limit_to((int) (filesize($path) / ($this->config()->min_download_bandwidth * 1024)));
} else {
// Remove the timelimit.
increase_time_limit_to(0);
}
// Clear PHP buffer, otherwise the script will try to allocate memory for entire file.
while (ob_get_level() > 0) {
ob_end_flush();
}
// Prevent blocking of the session file by PHP. Without this the user can't visit another page of the same
// website during download (see http://konrness.com/php5/how-to-prevent-blocking-php-requests/)
session_write_close();
readfile($path);
die;
}
示例14: extract
static function extract($f, $dir)
{
if ($f instanceof File) {
$source_file = $f;
} else {
$source_file = new File($f);
}
if ($dir instanceof Dir) {
$target_dir = $dir;
} else {
$target_dir = new Dir($dir);
}
$reader = $source_file->openReader();
$binarydata = $reader->read(3);
$data = unpack("a3", $binarydata);
if ($data[1] !== self::FF_ARCHIVE_HEADER) {
throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
}
$binarydata = $reader->read(2 + 2 + 2);
$data = unpack("v3", $binarydata);
if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
}
//properties
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$properties_length = $data[1];
if ($properties_length > 0) {
$binarydata = $reader->read($properties_length);
$data = unpack("a*", $binarydata);
$properties = PropertiesUtils::readFromString($data[1], false);
} else {
$properties = array();
}
//num entries
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$num_entries = $data[1];
$i = 0;
while ($i < $num_entries) {
//entry type
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$entry_type = $data[1];
//path length
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$path_length = $data[1];
//path
$binarydata = $reader->read($path_length);
$data = unpack("a*", $binarydata);
$path = $data[1];
if ($entry_type === self::ENTRY_TYPE_DIR) {
$d = $target_dir->newSubdir($path);
$d->touch();
}
if ($entry_type === self::ENTRY_TYPE_FILE) {
//compressed size
$binarydata = $reader->read(4);
$data = unpack("V", $binarydata);
$num_bytes = $data[1];
//compressed data
$compressed_file_data = $reader->read($num_bytes);
$uncompressed_file_data = gzuncompress($compressed_file_data);
$f = new File($target_dir->getPath() . $path);
$writer = $f->openWriter();
$writer->write($uncompressed_file_data);
$writer->close();
//sha1 sum
$sha1_checksum = $reader->read(20);
if (strcmp($sha1_checksum, sha1_file($f->getFullPath(), true)) !== 0) {
throw new InvalidDataException("La somma sha1 non corrisponde per il file : " . $f->getPath());
}
}
$i++;
}
$reader->close();
return true;
}
示例15: isLocalMissing
/**
* Returns true if the local file is not available
* @return bool
*/
public function isLocalMissing()
{
return !file_exists($this->owner->getFullPath()) || $this->containsPlaceholder();
}