User File Uploader at /profile/files
Permalink
I've added a fifth subpage, "/profile/files," to the user profile, which gives the logged in user an option to upload single or multiple files, and I'm wondering how to display the contents or a link to display the contents of the files that the user has uploaded at this same page, /profile/files. I created a files.php and added it to /controllers/profile; and I created a files.php and added it to /single_pages/profile.
/controllers/profile/files.php:
/single_pages/profile/files.php:
These files include cut-and-pasted code from /elements/files/upload_single.php. The upload works great; when a logged in user uploads a file at their /profile/files page, the file uploads correctly and appears in the file manager. I even doubled checked the Files table at phpmyadmin, and the file was uploaded exactly the way it would've been had it been uploaded via the dashboard/file manager. The problem: After the user chooses the file and clicks "upload" at their profile/files page, the page redirects tohttp://www.mysite.com/index.php/tools/required/files/importers/sing... which I assume is correct but the page is blank.
So, finally, how can I modify either one of these codes which I've included here, in order for the user to view the file or click a link to view the file at their profile/files page?
/controllers/profile/files.php:
<?php defined('C5_EXECUTE') or die("Access Denied."); Loader::model('user_files'); class ProfileFilesController extends Controller { var $helpers = array('html', 'form', 'date'); public function __construct() { $html = Loader::helper('html'); parent::__construct(); $u = new User(); if (!$u->isRegistered()) { $this->set('intro_msg', t('You must sign in order to access this page!')); Loader::controller('/login'); $this->render('/login'); } $this->set('ui', UserInfo::getByID($u->getUserID()));
Viewing 15 lines of 22 lines. View entire code block.
/single_pages/profile/files.php:
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <div id="ccm-profile-wrapper"> <?php Loader::element('profile/sidebar', array('profile'=> $ui)); ?> <?php $valt = Loader::helper('validation/token'); ?> <?php if ($mode == 'replace') { ?> <div id="ccm-profile-body"> <h2><?php echo t('File Manager')?></h2> <div> <h3><?php echo t('Upload File')?>:</h3> <form method="post" enctype="multipart/form-data" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/files/importers/single" class="ccm-file-manager-submit-single"> <input type="file" name="Filedata" class="ccm-al-upload-single-file" /> <?php echo $valt->output('upload');?> <input type="hidden" name="searchInstance" value="<?php echo $searchInstance?>" /> <input type="hidden" name="fID" value="<?php echo $fID?>" /> <img class="ccm-al-upload-single-loader" style="display:none;" src="<?php echo ASSETS_URL_IMAGES?>/dashboard/sitemap/loading.gif" />
Viewing 15 lines of 41 lines. View entire code block.
These files include cut-and-pasted code from /elements/files/upload_single.php. The upload works great; when a logged in user uploads a file at their /profile/files page, the file uploads correctly and appears in the file manager. I even doubled checked the Files table at phpmyadmin, and the file was uploaded exactly the way it would've been had it been uploaded via the dashboard/file manager. The problem: After the user chooses the file and clicks "upload" at their profile/files page, the page redirects tohttp://www.mysite.com/index.php/tools/required/files/importers/sing... which I assume is correct but the page is blank.
So, finally, how can I modify either one of these codes which I've included here, in order for the user to view the file or click a link to view the file at their profile/files page?
<form method="post" enctype="multipart/form-data" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/files/importers/single" class="ccm-file-manager-submit-single">
It is submitting to the concrete/tools/files/importers/single page. I'm not sure what you do to avoid that though -- worst case scenario you could copy the code out of THAT file into your own?