Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hey guys.

I am adding attachment functionality to some pages on the couch site I am currently working on.

What the client desires is the ability to upload a file, and have it displayed as an attachment just like you would see in an email.

I am going off of the following code in the couch Databound Forms :

Code: Select all
<cms:editable name='resume' required='1' allowed_ext='pdf, doc, docx' max_size='1024' type='securefile' />


The final version will be more like

Code: Select all
<cms:editable name='attachment' required='0' allowed_ext='pdf, doc, docx, xls, xlsx' max_size='1024' type='securefile' />


What I want to do is something similar to how php's pathinfo(); works, and simply weed out the extension. This is so I can put file type thumbnails next to the attachment listing at the bottom of the page.

Is there any function in couch that would do this?

EDIT:

Here is the code I am testing with. I am getting eval errors (syntax error, unexpected ':') from what looks to be the <cms:show> tag inside the pathinfo function :

Code: Select all
<cms:php>
      $extension = pathinfo(<cms:show attachment_file />);
    $extensionx = extension['extension'];
    echo $extensionx;
    </cms:php>
Okay, figured it out.

Code: Select all
<cms:repeatable name="attachments">
               <cms:editable type='file' name="attachment_file" allowed_ext='pdf, doc, docx, xls, xlsx' max_size='1024' />
            </cms:repeatable>
            <cms:show_repeatable "attachments" >
   <cms:php>
    $name = pathinfo('<cms:show attachment_file />')['filename'];
    $ext = pathinfo('<cms:show attachment_file />')['extension'];
   
    echo "<img height=25 src=\"<cms:show k_site_link />/attachext/$ext.png\"> <a href=\"<cms:show attachment_file />\"><b>$name.$ext</b></a><br>";
    </cms:php>
</cms:show_repeatable>
Thanks for sharing :)
Unable to upload .ico files. how can that be done?
Image
where innovation meets technology
@genxcoders,

.ico is not one of the allowed extensions in securefile, I'm afraid.

To add that as one, you'll have to modify the source file.
Please edit 'couch/addons/data-bound-form/securefile.php' and find the '$default_allowed_ext' array.
Add 'ico' to it and that should allow uploading these files.

Hope it helps.
i am not using DBF. Just a simple type='image'
to upload the favicon.ico file which is mentioned in between <title>...</title>

I saw this post also now: viewtopic.php?f=2&t=8405

there is an option of type='file'...
but then the problem is it will not show to the client what he has uploaded in the admin
Image
where innovation meets technology
As mentioned in the thread you pointed to -
KCFinder considers only gif, jpg, jpeg, png, bmp and xbm as valid image types. All other types will be rejected as GD library won't be able to process those as images.

Therefore, even if we were somehow able to get ico uploaded as image, you won't get to see the image preview you want.

So, I am sorry, but using 'file' is the only available option.
7 posts Page 1 of 1