Browse button

Discussion in 'Subrion CMS Plugins Discussion' started by spintercel, May 22, 2014.

  1. spintercel

    spintercel New Member

    Hi again :'), I was having problems with image upload code but Vasily B. just solved it. But now Im having this problem:



    upload.JPG



    The design is rare (I think css problem) and when I clic on ''Browse'' it redirects me to http://localhost/upload/#

    The code in index.tpl is:

    Code (Text):
                    <div class="fieldset-wrapper">
                        {if isset($data.image) && $data.image}
                                <a href="{printImage imgfile=$data.image fullimage=true url=true}" rel="ia_lightbox">
                                    {printImage imgfile=$data.image}
                                </a>
                        {/if}
                        {ia_html_file name='image' id='input-image'}
                </div>
    Any suggetions? Thank you :)
  2. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    Hello!

    This code can be applied to Admin Panel's pages only.
    At the front end you should use the following code:

    HTML:

    <div class="upload-wrap">
                    <div class="input-append">
                        <span class="span2 uneditable-input">{lang key='click_here_to_upload'}</span>
                        <span class="add-on">{lang key='browse'}</span>
                    </div>
                    <input type="file" name="image_upload[]" id="image_upload" class="upload-hidden">
                </div>

                {if $data.image}
                    <div class="thumbnail" style="width: {$config.thumb_width}px;">
                        {if $config.thumb_width == $config.image_width && $config.thumb_height == $config.image_height}
                           {printImage imgfile=$data.image.path width=$config.thumb_width height=$config.thumb_height title=$data.image.title thumbnail=1}
                       {else}
                           <a href="{printImage imgfile=$data.image.path url=true fullimage=true}" rel="ia_lightbox[image_upload]" style="max-width: {$config.thumb_width}px;">
                                {printImage imgfile=$data.image.path width=$config.thumb_width height=$config.thumb_height title=$data.image.title}
                            </a>
                        {/if}
                    </div>
                {/if}
     
  3. spintercel

    spintercel New Member

    Thanks for you response Alex. I changed the code, now the design is ok:

    testi1.JPG


    But it doesnt upload to the server when I submit. This is what I added in index.php:

    Code (Text):

    $data['image'] = $_POST['image'];
    ...
    ..
    ..


    if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name'])
                    {
                        $iaPicture = $iaCore->factory('picture');

                        $path = iaUtil::getAccountDir();
                        $file = $_FILES['image'];
                        $token = iaUtil::generateToken();
                        $info = array(
                            'image_width' => 1000,
                            'image_height' => 750,
                            'thumb_width' => 250,
                            'thumb_height' => 250,
                            'resize_mode' => iaPicture::CROP
                        );

                        $data['image'] = $iaPicture->processImage($file, $path, $token, $info);
                    }

    ...
    ....

     
    And no link is saved in the DB:

    testi2.JPG
    Last edited: May 23, 2014
  4. spintercel

    spintercel New Member

    Done, the problem was this line:

    Code (Text):
    <input type="file" name="image_upload[]" id="image_upload" class="upload-hidden">

    And I edited to:

    Code (Text):
    <input type="file" name="image" id="input-image" class="upload-hidden">

    So thank you very much Alex !
    Last edited: May 23, 2014
  5. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    Yes, everything is right. Glad, you solved the problem!
    Feel free to contact us if you need any further assistance.

Share This Page