How to create a new page in the zencart?

February 5, 2009

For creating a page in zencart we use this instructions:

1. From admin side goto ezpages and create new page with link .

2. create a page  named this

\includes\templates\template_default\templates\tpl_mypage_default.php

in this page copy the content from other page in same directory.

3.  write define(‘FILENAME_DEFINE_MYPAGE’, ‘define_mypage’); in the
\includes\filenames.php

4. create a page in this directory

\includes\languages\english\mypage.php

5. create a page in this directory
\includes\languages\english\html_includes\define_mypage.php

6. create a folder and page in this directory

\includes\modules\pages\mypage\header.php

Please copy the content from particular page in same directory.

7. go to define editor section from Tools menu in admin side. then select that page define_mypage and here you can insert description for that page.


Overriding layout for 1.5 series

October 2, 2008

There are html folder in particular template folder

Customise the Component Output for joomla 1.5 series

To override a component layout (for example the default layout in the article view), copy:

/components/com_content/views/article/tmpl/default.php

to:

/templates/rhuk_milkyway/html/com_content/article/default.php

Customise the Module Output

To override a module layout (for example the Latest News module ), copy:

/components/mod_latest_news/default.php

to:

/templates/rhuk_milkyway/html/mod_latest_news/default.php

Add New Module Styles

To add new module styles (chrome), add them to the following file:

/templates/rhuk_milkyway/html/modules.php

Customise the Pagination Links

To customise the way the items-per-page selector and pagination links display, edit the following file:

/templates/rhuk_milkyway/html/pagination.php


first Rails Aplication

September 9, 2008

Ror First application on rails 2.0
1. rails –database mysql hello
or rails -d mysql hello
2. create manually database on mysql
or rake db:create:all
3. ruby script/generate controller say hello

4. ruby script/server
5. type on http://localhost:3000/say/hello

for cearting table
script/generate scaffold Post title:string body:text
rake db:migrate

Steps
- rails -d mysql test
-cd test
—-manuially set the dtabase usernamr and pwd in database.yml file
-rake db:create:all
-ruby script/server (starting the server)
-ruby script/generate scaffold Movie title:string (for table cration)
-rake db:migrate

==for mongrel server
service mongrel_cluster restart
script/server –help
service nginx start

for including file
rendre:partial “path”;
render(:partial => ‘/controls/footer’)

for mongrel server steps

==start
1. copy mongrel_cluster.yml into config
changes that
2. insert some code in etc/ngix/*.conf
in that
upstream hello.rajesh {
server 127.0.0.1:8005;
}
and
server {
listen       81;
server_name  hello.rajesh;

root /sites/hello/public;

#charset koi8-r;

access_log  /var/log/nginx/hello.access.log  main;

location ~ ^/$ {
if (-f /index.html){
rewrite (.*) /index.html last;
}
proxy_pass  http://hello.rajesh;
}

location / {
if (!-f $request_filename.html) {
proxy_pass  http://hello.rajesh;
}
rewrite (.*) $1.html last;
}

location ~ .html {
root /sites/hello/public;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
root /sites/hello/public;
}

location / {
proxy_pass  http://hello.rajesh;
proxy_redirect     off;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

}

3. ln -s /sites/hello/config/mongrel_cluster.yml /etc/mongrel_cluster/hello.yml
4. chown -R mongrel:mongrel /sites/hello
==end
for creating only model and table
ruby script/generate model images_imagecategories image_id:integer imagecategories_id:integer
ruby script/generate model imagecategories_images images_id:integer imagecategories_id:integer


Ajax Uploading image, How to get image width and height for uploaded image, how to make validation for image width and height, how to call php function in javascript?

September 9, 2008

For that use following code for uplaoding image, there are 3 files to make this clear.

1.index.php

<!–
/* This scipt uses webtoolkit.js for Frame and aJAx style upload */
–>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en-US” lang=”en-US”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>Iframe Ajax for Upload</title>
<script type=”text/javascript” src=”webtoolkit.js”></script>
<script type=”text/javascript”>
function startCallback() {
// make something useful before submit (onStart)
return true;
}
function completeCallback(response) {
// make something useful after (onComplete)
var src_path =response;
//alert(response);
var img_obj  =document.getElementById(‘img_div’);
var newimg=document.createElement(‘img’);
img_obj.appendChild(newimg);
newimg.src = src_path;
newimg.onload=function()
{ // get an image width and hieght
new_w = img_obj.getElementsByTagName(‘img’)[0].width;
new_h =img_obj.getElementsByTagName(‘img’)[0].height;

if(new_w>100) //make neccessary validation depends on width adn hight
{
var ret = “<?php posting1(‘”+response+”‘);?>”;
alert(ret);
}
//remove the image from disp location here
img_obj.removeChild(newimg);
}
}
</script>
</head>
<body>

<form action=”my_upload.php” method=”post” onsubmit=”return AIM.submit(this, {‘onStart’ : startCallback, ‘onComplete’ : completeCallback})” enctype=”multipart/form-data”>
<div><label>Name:</label> <input type=”text” name=”form[name]” /></div>
<div><label>File:</label> <input type=”file” name=”form[file]” /></div>
<div><input type=”submit” value=”SUBMIT” /></div>
</form>
<hr/>
<div id=”img_div”></div>
</body>
</html>
<?php
function posting1($ret)
{
echo “code for update database and remove image for the same”.$ret;
}

?>


2.my_upload.php

<!–
/* In this page we can make upload logic by using php code */
–>
<?php
$fname =  $_FILES['form']['name']['file'];
$uploaded_path = “”.$fname;        ///var/www/html/demo/test/my_upload/
$ftname =  $_FILES['form']['tmp_name']['file'];

if(move_uploaded_file($ftname,$uploaded_path))
$ret = $uploaded_path;
else $ret =  $uploaded_path;
//$ret =”http://localhost:100/demo/test/”.$fname;
$disp_path =$fname;
echo $disp_path;
?>


3.webtoolkit.js
/**
*
*  AJAX IFRAME METHOD (AIM)
*  http://www.webtoolkit.info/
**/

AIM = {

frame : function(c) {

var n = ‘f’ + Math.floor(Math.random() * 99999);
var d = document.createElement(‘DIV’);
d.innerHTML = ‘<iframe style=”display:none” src=”about:blank” id=”‘+n+’” name=”‘+n+’” onload=”AIM.loaded(\”+n+’\')”></iframe>’;
document.body.appendChild(d);

var i = document.getElementById(n);
if (c && typeof(c.onComplete) == ‘function’) {
i.onComplete = c.onComplete;
}

return n;
},

form : function(f, name) {
f.setAttribute(‘target’, name);
},

submit : function(f, c) {
AIM.form(f, AIM.frame(c));
if (c && typeof(c.onStart) == ‘function’) {
return c.onStart();
} else {
return true;
}
},

loaded : function(id) {
var i = document.getElementById(id);
if (i.contentDocument) {
var d = i.contentDocument;
} else if (i.contentWindow) {
var d = i.contentWindow.document;
} else {
var d = window.frames[id].document;
}
if (d.location.href == “about:blank”) {
return;
}

if (typeof(i.onComplete) == ‘function’) {
i.onComplete(d.body.innerHTML);
}
}

}


Symfony project creation tips

September 3, 2008

for creating an project
on command line type and for SVN
1. crate a proejct
[root@local my_symfony]# php /var/www/html/demo/svn_symfony/data/bin/symfony init-project my_symfony
2. create an apllication
[root@local my_symfony]# php symfony init-app myapp
– if we have a sandox then we will directly write step2.
– run on wroser
http://localhost:100/demo/my_symfony/web/
–if you wnat to change the htaccess then do it here.

- create a SVN
svnadmin create my_svn

3. create a module ( for creating a page we must create module)
php symfony init-module [app_name] [module_name]
eg.php symfony init-module myapp mymodule
–run
http://localhost:100/demo/my_symfony/web/myapp_dev.php/mymodule/index
-now you can create mnodules/pages and multiple actions and templates


Stored Procedure

September 3, 2008

Stored Procedure
MySQL 5.0 finally introduces functionality for Stored Procedures. So what exactly are stored procedures?
A stored procedure is simply a procedure that is stored on the database server.
It is a some sql statments.
A stored procedure is a set of SQL statements stored on the server that takes in
certain arguments and processes that code with those arguments at execution time

A stored procedure is a set of SQL statements stored on the server that takes in certain arguments and
processes that code with those arguments at execution time.
It can be invoked simply by making a call to the procedure with the correct arguments.
The difference between stored procedures and other sets of SQL statements is that stored procedures
reside on the server and are pre-compiled.

Why we use that:
They wil lrun in all enviroments and there is no need to recreate the logics.It makes no
differnce on application environment, it remains consistent.
They can reduce network traffics. there is no need to send result sets and new
queries back and forth from application server to database server.
1. Better performance  Stored procedures are faster because they are pre-compiled SQL code. This reduces the “Compile and Execute” step to just “Execute’ in most cases.  Also, only the call to the stored procedure needs to be sent to the server instead of chunks of information – this reduces the information that needs to be sent to the server and acts like a call to a remote procedure. This is an advantage when it comes to code that is called repeatedly. However, the load on the server is another point to consider since most of the processing will now be done on the server.

2. Easier to maintain  Since all the SQL can now be stored on the server, it is easier to make changes to the stored procedure than to a bunch of SQL statements distributed all over the application.

3. Security  Although the use of stored procedures is not by itself a guarantee of security, it can be used to create an environment where applications and users can only access database tables through the stored procedures, instead of giving them direct access to the tables. The benefit is a layer of abstraction.

4. Optimization  When a SQL statement is parsed by the server, it is optimized internally by the server. If a bunch of SQL statements are sent to the server, repeatedly, they have to be optimized each time. The SQL statements in the stored procedure that is in memory have to only be optimized once and an execution plan is created for the SQL statements in the stored procedure.

Example:
mysql> create stored procedure my_prodc() select “tets”
mysql> call my_proc()

Parameters:
there are 3 parameters
IN: The default. This parameter is passed to the procedure, and can change inside the procedure,
but remains unchanged outside.
OUT: No value is supplied to the procedure (it is assumed to be NULL), but it can be modified inside
the procedure, and is available outside the procedure.
INOUT: The characteristics of both IN and OUT parameters. A value can be passed to the procedure,
modified there as well as passed back again.
Mastery of stored procedures does require knowledge of session variables.
Most of you probably know how to use session variables already, but if not, the concept is simple.


Paypal integration instruction

September 3, 2008

For sandbox
-create developer central a/c
-creaet multiple Paypal Test a/c for buyer and merchants

make a form in your site which will hidden
this is the default format for paypal
1. <FORM action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
2. <INPUT TYPE=”hidden” name=”variableName” value=”allowedValue”>

Buy Now buttons – <INPUT TYPE=”hidden” name=”cmd” value=”_xclick”>
Donate buttons – <INPUT TYPE=”hidden” name=”cmd” value=”_donations”>
Subscribe buttons – <INPUT TYPE=”hidden” name=”cmd” value=”_xclick-
subscriptions”>
Shopping cart buttons – <INPUT TYPE=”hidden” name=”cmd” value=”_cart”>

The following are passthrough variables:
custom
item_number or item_number_x
invoice

HTML Code for FORM Prepopulation
<form action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
for sandbox
https://www.sandbox.paypal.com/cgi-bin/webscr
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=”seller@designerfotos.com”>
<input type=”hidden” name=”item_name”
value=”Memorex 256MB Memory Stick”>
<input type=”hidden” name=”item_number” value=”MEM32507725″>
<input type=”hidden” name=”amount” value=”3″>
<input type=”hidden” name=”tax” value=”1″>
<input type=”hidden” name=”quantity” value=”1″>
<input type=”hidden” name=”no_note” value=”1″>
<input type=”hidden” name=”currency_code” value=”USD”>
<!– Enable override of payer’s stored PayPal address. –>
<input type=”hidden” name=”address_override” value=”1″>
<!– Set prepopulation variables to override stored address. –>
<input type=”hidden” name=”first_name” value=”John”>
<input type=”hidden” name=”last_name” value=”Doe”>
<input type=”hidden” name=”address1″ value=”345 Lark Ave”>
<input type=”hidden” name=”city” value=”San Jose”>
<input type=”hidden” name=”state” value=”CA”>
<input type=”hidden” name=”zip” value=”95121″>
<input type=”hidden” name=”country” value=”US”>
<input type=”image” name=”submit” border=”0″
src=”https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif”
alt=”PayPal – The safer, easier way to pay online”>
</form>

<INPUT TYPE=”hidden” name=”charset” value=”utf-8″>
<INPUT TYPE=”hidden” NAME=”return” value=”URLspecificToThisTransaction”> (default paypal own return )
<INPUT TYPE=”hidden” NAME=”currency_code” value=”CurrencyCode”> ( default USD)
<INPUT TYPE=”hidden” name=”address_override” value=”1″>

===IPN ( instant payment notification)=notify_url======

====Allowable Values for the cmd HTML Variable==
Value of cmd            Description
_xclick          The button that the person clicked was a Buy Now button.
_donations       The button that the person clicked was a Donate button.
_xclick-subscriptions  The button that the person clicked was a Subscribe button.
_oe-gift-certificate   The button that the person clicked was a Buy Gift Certificate button.
_cart             For shopping cart purchases; these additional variables specify the
kind of shopping cart button that the person clicked:
add – Add to Cart buttons for the PayPal Shopping Cart
display – View Cart buttons for the PayPal Shopping Cart
upload – The Cart Upload command for third party carts
_s-xclick          The button that the person clicked was protected from tampering by
using encryption.

============= ==IPN back=============

// read the post from PayPal system and add ‘cmd’
$req = ‘cmd=_notify-validate’;

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= “&$key=$value”;
}

// post back to PayPal system to validate
$header .= “POST /cgi-bin/webscr HTTP/1.0\r\n”;
$header .= “Content-Type: application/x-www-form-urlencoded\r\n”;
$header .= “Content-Length: ” . strlen($req) . “\r\n\r\n”;
$fp = fsockopen (’ssl://www.paypal.com’, 80, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, “VERIFIED”) == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, “INVALID”) == 0) {
// log for manual investigation
}
}
fclose ($fp);
}


Web Service

September 3, 2008

What is a Web Service?
A “web service” is a network accessible interface to application functionality built using XML and usually HTTP.
Standard Setup

* • Clients make requests and servers reply
* • Communication done over the Internet

Four Basic Steps

* 1. Web Services client script builds up the request
* 2. Client sends the request to server using HTTP
* 3. Server replies and returns an XML document with results
* 4. Client parses XML
Three forms of Web Services

* • SOAP
* • XML-RPC
* • REST

SOAP

* • Formerly known as Simple Object Access Protocol.
* • Uses XML, but you never need to touch it.
* • Which is good, because SOAP is messy to look at.
* • You just call functions and manipulate arrays. (Unless you want to.)
* • A few PHP implementations: PEAR::SOAP, PHP-SOAP, NuSOAP

Make a Request
Load in the SOAP Client
<?php require ‘SOAP/Client.php’; ?>
Generate Client Proxy (for Amazon.Com)
<?php
// We have human readable explanation of the API.
$wsdl_url = ‘http://soap.amazon.com/schemas3/AmazonWebServices.wsdl’;
$WSDL = new SOAP_WSDL($wsdl_url);
$client = $WSDL->getProxy();
?>
Web Service Description Language (WSDL)
Machine readable description (XML) of a web service. Used here to define server’s methods and parameters.
SOAP Server
<?php
require_once ‘SOAP/Server.php’;

class SOAP_Server_rot13 {
function rotate($input) {
return str_rot13($input);
}
}

$server = new SOAP_Server;
$soapclass = new SOAP_Server_rot13();
// Associate PHP class with SOAP message
$server->addObjectMap($soapclass ,’urn:SOAP_Server_rot13′);
$server->service($HTTP_RAW_POST_DATA);
?>

XML-RPC

* • XML Remote Procedure Call
* • Similar to SOAP, but less complex
* • Which is its biggest advantage
* • And its biggest disadvantage
* • But it is often “good enough”
* • But, SOAP has better buzzword compliance

REST

* • REpresentational State Transfer
* • Make URI request using existing HTTP methods: GET / POST / PUT / DELETE.
* • Data returned as XML, and you do need to touch it.
* • Which is good, because it’s not complicated.
* • Many ways to parse XML: SAX / DOM / XSLT / SimpleXML


Document uplaoding and downloading instruction

September 3, 2008

#This is the sample appliocation code ,Please change as per your requirements.

==========For Document uploading============
1. model
-dcument.rb
def upload=(input_data)
if input_data != “”
self.filename = input_data.original_filename
self.documenttype = input_data.content_type.chomp
self.content = input_data.read
self.documentsize = input_data.size
end
end
2. controller
#display the doc /dopwnlaod
def showdoc# for download document
doc_id = params[:id]
#@doc = Document.find(doc_id)
#send_data(@doc.content, :type => @doc.documenttype,
#                 :filename => @doc.filename,
#                 :disposition => ‘inline’)
#
if doc_id != 0
begin
@doc = Document.find(doc_id)
if !(@doc.documentsize).blank?
send_data(@doc.content, :type => @doc.documenttype,
:filename => @doc.filename,
:disposition => ‘disposition’)
#increment download count
@count =(@doc.downloadcount)+1
@up = Document.update(doc_id, :downloadcount => @count)
#end incerement
return
end
rescue
end
end
flash[:notice] = “Error occured during downlaoding.”
redirect_to :action => “index”
end
#save document
def savedoc
if params[:doc][:title].blank?
flash[:notice] = “Title cannot be left blank.”
elsif  params[:doc][:upload].blank?
flash[:notice] = “Please select Document.”
else
@doc = Document.new(params[:doc])
if @doc.save
flash[:notice] = “Document was successfully created.”
redirect_to :action => “index”
return
else
flash[:notice] = “Error occured during Uploading.”
end
end
redirect_to :action => “adddoc”
end
#update document
def updatedoc
if params[:doc][:title].blank?
flash[:notice] = “Title cannot be left blank.”
else
@items = Document.find(params[:id])
if @items.update_attributes(params[:doc])
flash[:notice] = ‘Document was successfully updated.’
redirect_to :action => “index”
return
end
end
redirect_to :action => “editdoc”,:id=>params[:id]
end

3. view
-showdocument.rhtml
<% @items_all = Document.find(:all)
for @items in @items_all %>
<%=  link_to ‘Download’, :id => @items.id, :action => “showdoc” %>
<% end %>
-adddocument.rhtml
<%= form_tag ({:action => ’savedoc’},:multipart => true) %>
<table>
<tr><td>Title</td>
<td><%= text_field (“doc”,”title”,:size=>”30″) %><span id=”red”>&nbsp;*</span>
</td></tr>
<tr><td>Description</td>
<td><%= text_area (“doc”,”description”,:cols=>”28″,:rows=>4)%>
</td></tr>

<tr><td>Upload Document</td><td>
<%= file_field ‘doc’, ‘upload’, :size => “20″ %><span id=”red”>&nbsp;*</span>
</td></tr>
</tr>
<tr><td colspna=”2″>&nbsp;</td></tr>
<tr><td colspna=”2″><input type=”submit” name =”save” value=”Add”></td></tr>
</table>
</form>
4. database table structure
-document table
id=int
title=varchar
description=varchar
filename-varchar
documenttype=varrchar
documentsize-bigint(11)
content – longblob
downlaodcount-bigint(11)


Image uploading Instruction with sample

September 3, 2008

#This is the sample appliocation code ,Please change as per your requirements.

======Image Uploading instruction=========

1.routes.rb
#this is for image display
map.with_options :controller => ‘images’ do |image|
image.show ‘images/show/:size/:id/:default_image’, :action => ’show’, :id => 0, :default_image => nil,  :requirements => {:size => /(tiny|small|medium|original)/}
end
2. model
-image.rb file

require ‘RMagick’
class Image < ActiveRecord::Base
def thumb=(input_data)
if input_data != “”
self.name = input_data.original_filename
self.content_type = input_data.content_type.chomp
self.image_original = input_data.read
img = Magick::Image.from_blob(self.image_original)
original_height = img[0].rows
original_width = img[0].columns
self.height = original_height
self.width = original_width
tiny_height = 32
tiny_width = 32
small_height = 85
small_width = 85
medium_height = 180
medium_width = 180
# resize the photo keeping aspect ratio
if original_height > original_width
tiny_width = original_width * tiny_height / original_height
small_width = original_width * small_height / original_height
medium_width = original_width * medium_height / original_height
else
tiny_height = original_height * tiny_width / original_width
small_height = original_height * small_width / original_width
medium_height = original_height * medium_width / original_width
end
self.image_tiny = img[0].thumbnail(tiny_width, tiny_height).to_blob
self.image_small = img[0].thumbnail(small_width, small_height).to_blob
self.image_medium = img[0].thumbnail(medium_width, medium_height).to_blob
end
end
end

3. controller
-images_controller.rb file
#this is for image display
def show
# verify valid size parameter here
valid_display_size = ["tiny", "small", "medium", "original"]
display_size = (valid_display_size.include?params[:size])?params[:size]:”medium”
#display_size = params[:size]?params[:size]:”medium”
image_id = params[:id]
default_image = params[:default_image]?params[:default_image]:”no_photo_#{display_size}”
if image_id != 0
begin
@image = Image.find(image_id)

if !(eval(“@image.image_#{display_size}”)).blank?
send_data(eval(“@image.image_#{display_size}”), :type => @image.content_type,
:filename => @image.name,
:disposition => ‘inline’)
return
end
rescue
end
#   # show default image here
#   #send_image(“#{RAILS_ROOT}/public/images/#{default_image}”)
#   @no_image = File.open(“#{RAILS_ROOT}/public/images/#{default_image}.png”,”r”)
#   send_data(@no_image.read, :type => “image/png”,
#              :filename => “#{default_image}.png”,
#              :disposition => ‘inline’)
end
#else
# show default image here
#send_image(“#{RAILS_ROOT}/public/images/#{default_image}”)
@no_image = File.open(“#{RAILS_ROOT}/public/images/#{default_image}.png”,”r”)
send_data(@no_image.read, :type => “image/png”,
:filename => “#{default_image}.png”,
:disposition => ‘inline’)
#end
end

#save iamge
def saveimage
if params[:image][:title].blank?
flash[:notice] = “Title cannot be left blank.”
elsif  params[:image][:thumb].blank?
flash[:notice] = “Please select Image.”
else
@picture = Image.new(params[:image])
if @picture.save
flash[:notice] = “Item was successfully created.”
redirect_to :action => “index”
return
else
flash[:notice] = “Error occured during insertion.”
end
end
redirect_to :action => “addimage”
end

#update iamge
def updateimage
if params[:image][:title].blank?
flash[:notice] = “Title cannot be left blank.”
else
@items = Image.find(params[:id])
if @items.update_attributes(params[:image])
flash[:notice] = ‘Photo was successfully updated.’
redirect_to :action => “index”
return
end
end
redirect_to :action => “editimage”,:id=>params[:id]
end
4. view
-add_image.rhtml=
<%= form_tag ({:action => ’saveimage’},:multipart => true) %>

<table>
<tr><td>Title</td>
<td><%= text_field (“image”,”title”,:size=>”30″) %><span id=”red”>&nbsp;*</span>
</td></tr>
<tr><td>Description</td>
<td><%= text_area (“image”,”description”,:cols=>”28″,:rows=>4)%>
</td></tr>
<tr><td>Upload Image</td><td>
<%= file_field ‘image’, ‘thumb’, :size => “20″ %><span id=”red”>&nbsp;*</span>
</td></tr>
</table></form>
#show image/display
<% @items_all = Image.find(:all)
for @items in @items_all %>
<%= image_tag(“/images/show/small/#{@items.id ? @items.id : “0″}/no_photo_#{“”}_small”, :alt => “Image not available”) %>
<%= image_tag(“/images/show/medium/#{@items.id ? @items.id : “0″}/no_photo_#{“”}_medium”, :alt => “Image not available”) %>
<% end %>
5. database structure
image table===
id=int
title=varchar
name=varchar
content_type=varchar
image_tiny=midiumblob
image_small=midiumblob
image_midium==midiumblob
image_original==midiumblob
height=bigint(11)
width=bigint(11)