getStorageLocation() публичный Метод

Get the full path to the storage location of the file on disk.
public getStorageLocation ( ) : string
Результат string
Пример #1
0
}
$attachmentId = (int) ltrim($attachment, " 0\t\n\r");
$attachmentObj = new Attachment($attachmentId);
if (!$attachmentObj->exists()) {
    header('HTTP/1.0 404 Not Found');
    echo 'Error 404: File not found';
    exit;
}
header('Content-Type: ' . $attachmentObj->getMimeType());
if ($g_download == 1) {
    header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
} else {
    if ($g_show_in_browser == 1) {
        header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
    } else {
        if (!$attachmentObj->getContentDisposition() && strstr($attachmentObj->getMimeType(), 'image/') && (strstr($_SERVER['HTTP_ACCEPT'], $attachmentObj->getMimeType()) || strstr($_SERVER['HTTP_ACCEPT'], '*/*'))) {
            header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
        } else {
            header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
        }
    }
}
header('Content-Length: ' . $attachmentObj->getSizeInBytes());
$filePath = $attachmentObj->getStorageLocation();
if (file_exists($filePath)) {
    readfile($filePath);
} else {
    header('HTTP/1.0 404 Not Found');
    echo 'Error 404: File not found';
    exit;
}
Пример #2
0
 /**
  * Process multi-upload file.
  *
  * @param string $p_tmpFile
  * @param string $p_newFile
  * @param int $p_userId
  *
  * @return Image|NULL
  */
 public static function ProcessFile($p_tmpFile, $p_newFile, $p_userId = NULL, $p_attributes = NULL)
 {
     $tmp_attachment = new Attachment();
     $tmp_name = $tmp_attachment->getStorageLocation() . "/" . $p_tmpFile;
     //$tmp_name = $GLOBALS['Campsite']['FILE_DIRECTORY'] . '/' . $p_tmpFile;
     $file = array('name' => $p_newFile, 'tmp_name' => $tmp_name, 'type' => mime_content_type($tmp_name), 'size' => filesize($tmp_name), 'error' => 0);
     $attributes = array('fk_user_id' => $p_userId, 'fk_description_id' => 0, 'Source' => 'local', 'Status' => 'approved');
     if ($p_attributes != NULL && is_array($p_attributes)) {
         foreach ($p_attributes as $key => $value) {
             $attributes[$key] = $value;
         }
     }
     try {
         $image = self::OnFileUpload($file, $attributes, null, true);
         return $image;
     } catch (PEAR_Error $e) {
         return NULL;
     }
 }
Пример #3
0
 public function uploadAction()
 {
     global $Campsite;
     $auth = Zend_Auth::getInstance();
     $userId = $auth->getIdentity();
     $_FILES['file']['name'] = preg_replace('/[^\\w\\._]+/', '', $_FILES['file']['name']);
     $mimeType = $_FILES['file']['type'];
     $type = explode('/', $mimeType);
     if ($type[0] == 'image') {
         $file = Plupload::OnMultiFileUploadCustom($Campsite['IMAGE_DIRECTORY']);
         $image = Image::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved', 'Date' => date('Y-m-d')));
         $this->view->response = $image->getImageId();
     } else {
         if ($type[1] == 'pdf') {
             $attachment = new Attachment();
             $attachment->makeDirectories();
             $file = Plupload::OnMultiFileUploadCustom($attachment->getStorageLocation());
             $document = Attachment::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved'));
             $this->view->response = $document->getAttachmentId();
         }
     }
 }
Пример #4
0
<IMG SRC="<?php echo $attachmentObj->getAttachmentUrl(); ?>" BORDER="0" ALT="<?php echo htmlspecialchars($attachmentObj->getDescription($f_language_selected)); ?>">
</div>
<P>
<?php } ?>
<FORM NAME="dialog" METHOD="POST" ACTION="do_edit.php" >
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="6" class="table_input" width="400px">
<TR>
	<TD COLSPAN="2">
		<B><?php  p($title); ?></B>
		<HR NOSHADE SIZE="1" COLOR="BLACK">
	</TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php putGS('File Name'); ?>:</TD>
	<TD><?php echo htmlspecialchars($attachmentObj->getFileName()); ?> &nbsp; <A
		HREF="/attachment/<?php p(basename($attachmentObj->getStorageLocation())); ?>"><IMG
		TITLE="<?php putGS('Download'); ?>" BORDER="0" ALIGN="absmiddle" SRC="<?php p($Campsite["ADMIN_IMAGE_BASE_URL"]);?>/download.png" /></A></TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php  putGS('Description'); ?>:</TD>
	<TD>
	<INPUT TYPE="TEXT" NAME="f_description" VALUE="<?php echo htmlspecialchars($attachmentObj->getDescription($f_language_selected)); ?>" class="input_text" SIZE="32" <?php p($isReadOnly); ?>>
	</TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php putGS('File Size'); ?>:</TD>
	<TD><?php p(camp_format_bytes($attachmentObj->getSizeInBytes())); ?></TD>
</TR>
<TR>
	<TD ALIGN="left" colspan="2" style="padding-left: 15px;"><?php  putGS("Should this file only be available for this translation of the article, or for all translations?"); ?></TD>
</TR>
Пример #5
0
<?php
/**
 * @package Newscoop
 *
 * @author Mihai Nistor <*****@*****.**>
 * @copyright 2010 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl.txt
 * @link http://www.sourcefabric.org
 */

require_once($GLOBALS['g_campsiteDir']. "/classes/Plupload.php");
require_once($GLOBALS['g_campsiteDir'].'/classes/Attachment.php');

if (!$g_user->hasPermission('AddFile')) {
	camp_html_display_error(getGS("You do not have the right to add files."));
	exit;
}

$attachmentObj = new Attachment();
$attachmentObj->makeDirectories();
// Plupload
$files = Plupload::OnMultiFileUpload($attachmentObj->getStorageLocation());
?>
Пример #6
0
$f_article_number = Input::Get('f_article_number', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
// Check input
if (!Input::IsValid()) {
    camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), null, true);
    exit;
}
if (!$g_user->hasPermission("DeleteFile")) {
    camp_html_display_error($translator->trans("You do not have the right to delete file attachments.", array(), 'article_files'), null, true);
    exit;
}
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans("Article does not exist."), null, true);
    exit;
}
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error($translator->trans('Attachment does not exist.', array(), 'article_files'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
ArticleAttachment::RemoveAttachmentFromArticle($f_attachment_id, $f_article_number);
$logtext = $translator->trans('File #$1 "$2" unattached', array('$1' => $attachmentObj->getAttachmentId(), '$2' => $attachmentObj->getFileName()), 'article_files');
Log::ArticleMessage($articleObj, $logtext, null, 39);
$attachmentFileName = $attachmentObj->getFileName();
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('attachments');
// Go back to article.
camp_html_add_msg($translator->trans("File \$1 unattached.", array('$1' => $attachmentFileName), 'article_files'), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
Пример #7
0
    exit;
}
if (!$g_user->hasPermission('DeleteFile')) {
    camp_html_display_error(getGS('You do not have the right to delete files.'), null, true);
    exit;
}
$f_debate_nr = Input::Get('f_debate_nr', 'int', 0);
$f_debateanswer_nr = Input::Get('f_debateanswer_nr', 'int', 0);
$f_fk_language_id = Input::Get('f_fk_language_id', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error(getGS('Attachment does not exist.'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
if (!is_writable(dirname($filePath))) {
    camp_html_add_msg(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $filePath, basename($attachmentObj->getStorageLocation())));
    //camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
    exit;
}
$DebateAnswerAttachment = new DebateAnswerAttachment($f_debate_nr, $f_debateanswer_nr, $f_attachment_id);
$DebateAnswerAttachment->delete();
// Go back to upload screen.
camp_html_add_msg(getGS("File '\$1' deleted.", $attachmentObj->getFileName()), "ok");
$attachmentObj->delete();
?>
<script>
location.href="popup.php?f_debate_nr=<?php 
p($f_debate_nr);
?>
Пример #8
0
    /**
     * Process multi-upload file.
     *
     * @param string $p_tmpFile
     * @param string $p_newFile
     * @param int $p_userId
     *
     * @return Image|NULL
     */
    public static function ProcessFile($p_tmpFile, $p_newFile, $p_userId = NULL)
    {
        $tmp_attachment = new Attachment();
        $tmp_name =  $tmp_attachment->getStorageLocation()."/". $p_tmpFile;
        $file = array(
            'name' => $p_newFile,
            'tmp_name' => $tmp_name,
            'type' => mime_content_type($tmp_name),
            'size' => filesize($tmp_name),
            'error' => 0,
        );

        $attributes = array(
            'fk_user_id' => $p_userId,
            'fk_description_id' => 0
        );

        try {
            $image = self::OnFileUpload($file, $attributes, null, true);
            return $image;
        } catch (PEAR_Error $e) {
            return NULL;
        }

    } // fn ProcessImage