If you can download the file outside of Firefox, you can use
filetodownload=file-to-download.ext
wget http://www.example.org/"$filetodownload" -O "$filetodownload"
#"I want to create a directory beside the downloaded file automatically"
#You didn't specify a dir name
mkdir "$filetodownload"
Otherwise, you'll have to monitor the file's download progress and when it's finished, make the directory "beside the downloaded file". The following worked for me (but I couldn't make a dir with the same name as the file). It looks at all files though, including hidden ones. Modify as needed.
#! /bin/bash
while [ 1 ]
do
for files in $(find . -maxdepth 1 -mmin -1 -type f)
do
testbefore=$(ls -l $files | awk '{print $5$6$7$8$9}')
sleep 2
testafter=$(ls -l $files | awk '{print $5$6$7$8$9}')
if [ $testbefore = $testafter ]
then
# echo $testbefore
mkdir $(basename "$files")_
fi
sleep 5
done
done