Home > PHP, Smarty > Smarty template check file image exist

Smarty template check file image exist

Kiểm tra file hình có tồn tại hay không ? trong smarty template

$absolute_path
– server: // /home/www/web/
– localhost: // C:\\xampp\htdocs\web\data\
{assign var=fileImg value=$product.thumb_img}
{assign var=”image” value=”$absolute_path$fileImg”}

{if file_exists($image)}
<img src=”$image” />
{else}
File hình không tồn tại
{/if}

file_exist là một plug in có sẵn trong các version smarty (smarty/plugins/)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: