3

I have created a upload modal field to upload content into the images directory and it all works perfectly fine, except the redirect after the upload.

This is the upload Form in the modal window:

<form action="<?php echo JUri::base(); ?>index.php?option=com_file_manager&amp;task=file.upload&amp;tmpl=component&amp;<?php echo $this->session->getName() . '=' . $this->session->getId(); ?>&amp;<?php echo JSession::getFormToken();?>=1&amp;view=file" id="uploadForm" class="form-horizontal" name="uploadForm" method="post" enctype="multipart/form-data">
    <div id="uploadform" class="well">
        <fieldset id="upload-noflash" class="actions">
            <div class="control-group">
                <div class="control-label">
                    <label for="upload-file" class="control-label"><?php echo JText::_('COM_MEDIA_UPLOAD_FILE'); ?></label>
                </div>
                <div class="controls">
                    <input type="file" id="upload-file" name="Filedata[]" multiple /><button class="btn btn-primary" id="upload-submit"><i class="icon-upload icon-white"></i> <?php echo JText::_('COM_MEDIA_START_UPLOAD'); ?></button>
                </div>
            </div>
        </fieldset>
                <input type="hidden" name="return-url" value="<?php echo base64_encode('index.php?option=com_fal_manager&amp;view=file&amp;layout=modal&amp;tmpl=component'); ?>" />

    </div>
</form>

And this is how the redirect looks in the controller:

public function upload() {
        // Check for request forgeries
        JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
        $files        = $this->input->files->get('Filedata', '', 'array');
        $return       = $this->input->post->get('return-url', null, 'base64');
        $this->folder = $this->input->get('folder', '', 'path');
        if ($return) {
            $this->setRedirect(base64_decode($return));
        }
}

I just need it to take me back to the original place i was before i uploaded it, the url of the modal is:

index.php?option=com_file_manager&view=videofile&layout=modal&tmpl=component&function=jSelectVideofile_jform_video

and after upload:

index.php?option=com_file_manager&view=videofile&layout=modal&tmpl=component&function=jSelectVideofile_jform_video

Weird I know, its the same url, but its not the same page.. It takes me to the list view of that page.

Any Help Greatly Appreciated

  • Where does this modal field reside? Is this a custom component you are building? – FFrewin May 19 '14 at 21:15
3

The problem turned out to be something as simple as &amp;, Simple changing:

<input type="hidden" name="return-url" value="<?php echo base64_encode('index.php?option=com_file_manager&amp;view=file&amp;layout=modal&amp;tmpl=component'); ?>" />

to:

<input type="hidden" name="return-url" value="<?php echo base64_encode('index.php?option=com_file_manager&view=file&layout=modal&tmpl=component'); ?>" />

Did the trick. Thank you all for your inputs.

1

You have view=files in your return-url hidden input of the form. Then in the controller you assign it to $return var and redirect using it. That is why you are being redirect to the list view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.