shell script for ftp files passed in command line argument

i want to write a shell script function that will ftp the files passed in the command line . i have written a shell script for ftp but how will it do for all files passed in command line argument ,

i am passing 4 files as argument

./ftp.sh  file1 file2 file3 file4 

code written by me :---

if [ $# -eq 0 ]
        then
                echo "Enter the files to be ftp as Arugment:- "
                exit 1
        fi
echo " "
echo "$@"


hostname="someip"
username="root"
password="root"

ftpbuild(){
sftp  $hostname <<EOF
cd /tmp
mput $1  or $* ( getting error for both )
quit
EOF
}

ftpbuild - calling the function here .

getting error and not getting ftped .

do i need to declare any array here for i will use for loop for this . but if i will use for loop then for 5 files it will call the function 5 five as ftp connection ,.,

Help me out here

man sftp 

look at the -b option

but how will it help me reading from command line argument .

The ftp command is not intended to be used in scripts.

Use the ncftp family of commands instead.

Better still, use scp if you can.

Also your problem with $1 is that within the function ftpbuild you can only access the parameters passed to that function when it was called not those passed to the whole script. call ftpbuild like this to pass the main script parameters on to the function:

ftpbuild $@

Build .netrc file in your script and then call ftp.
google .netrc for samples.