docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 6.1Web Developer ManualIf Tags
Copyright  2018, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com



<else>
<elseif>
<false>
<if>
<if accept>
<if client>
<if clientvar>
<if config>
<if cookie>
<if date>
<if defined>
<if domain>
<if exists>
<if expr>
<if false>
<if group>
<if internal-exists>
<if ip>
<if kerberos-auth>
<if language>
<if match>
<if Match>
<if module>
<if pragma>
<if prestate>
<if recaptcha-verify>
<if referrer>
<if scope>
<if sizeof>
<if supports>
<if time>
<if true>
<if type-from-data>
<if type-from-filename>
<if user>
<if variable>
<if Variable>
<if variable-exists>
<then>
<true>

<if type-from-data></if>

Provided by module: Tags: RXML tags

Compares if the variable's data is known content type and tries to match that content type with the content type pattern.

This test is currently only capable of recognizing several common image formats. If the content format isn't recognized then the fallback content type in the Content Types module is tested against the pattern. That type is "application/octet-stream" by default. That also means that if the variable content is unknown and there is nothing to test the content type from, it will always return true:

<set variable='var.fake-image' value='fakedata here'/> <if type-from-data='var.fake-image'>It is an image</if>
It is an image

While the correct way would be:

<set variable='var.fake-image' value='fakedata here'/> <if type-from-data='var.fake-image is application/octet-stream'> Not known content type! </if>
Not known content type!

This is an Eval plugin.

Related tags: <if#type-from-filename>, <cimg>, <guess-content-type>, <emit#dir>.

<nocache> <form method='post' enctype='multipart/form-data'> <input type='file' name='image' /> <input type='submit' name='upload' /> </form> <if variable='form.image' and='' sizeof='form.image < 2048000'> File is less than 2MB <if type-from-data='form.image is image/*'> It's an image! </if> <elseif type-from-filename='form.image is text/*'> It is a text file of some sort. </elseif> <elseif type-from-filename='form.image is application/msword,application/pdf'> The image is a MS word- or pdf file. </elseif> <elseif type-from-filename='form.image is application/octet-stream'> Invalid content type, type is unknown! </elseif> </if> <else>File larger than 2MB</else> </nocache>