How to handle file uploads from pages module

edited February 2012 in Bug Reports
I have a layout and i've added a variable where I want a user to be able to upload a file. Is this possible in the pages module and if so, can you point in a starting direction?

I have this in MY_fuel_layouts

$config['layout_fields']['about'] = array( 'copy' => array('copy' => lang('layout_field_main_copy')), 'page_title' => array('label' => lang('layout_field_page_title')), 'meta_description' => array('label' => lang('layout_field_meta_description')), 'meta_keywords' => array('label' => lang('layout_field_meta_keywords')), 'heading' => array('label' => 'Heading'), 'pats_blurb' => array('label' => 'Pat\'s Blurb', 'type' => 'textarea'), 'pats_image' => array('label' => 'Pats Image', 'type' => 'file'), 'body' => array('label' => lang('layout_field_body'), 'type' => 'textarea', 'description' => lang('layout_field_body_description')), );

Comments

  • edited February 2012
    What if you change the file upload two actually to fields. One being the text field that captures the name of the file uploaded and the other being the field that uploads the file like below:

    'pats_image' => array('label' => 'Pats Image', 'type' => 'text'), 'pats_image_upload' => array('label' => 'Pats Image Upload', 'type' => 'file'),
  • Doing that seems to allow me to upload an image. I'm then setting that image in the page like this:

    <?php $patsImage = fuel_var('pats_image_upload'); ?> <img src="<?php echo img_path($patsImage); ?>" class="portfolio-image" alt="sample image" />

    This leaves me with 2 more questions.
    1. If i go to the pages module and then click on this page, If i change any textfield, but forget to upload the image again, my image is gone. Is there a way to make it so that if the upload field is blank, leave the image that already exists?

    2. Using the code posted above, if I try to click on the pencil for the image to edit it inline, I can choose the file from my computer, but when I click save, it doesn't actually upload the file or reload the page. Is there a fix for this?
  • edited May 2012
    I believe some of these file upload issues you are experience will be addressed in the next major release
  • When's the next major release scheduled to come out?
  • edited 7:09AM
    We don't have a timeline yet but are actively working... sorry... I know that doesn't help. We aren't trying to be secretive, we just need to work it in among other projects.
Sign In or Register to comment.