>>>>> ts,

t>  What is the value of $SAFE ?
$SAFE -> 1
t>  How "someFileName" is generated ? Can you post the script ?
But.. it's too big :)

#!/bhome/part2/01/gloria/ruby/bin/ruby

require 'mysql'
require 'cgi'
require 'templates'
require '../site/global'
require '../site/image'

cgi = CGI.new


action = cgi['action'][0].read.to_s
ImagesDir = ""

case action
	when 'add'
	begin
		category_id = cgi['category'][0].read
		
		sql = makeSQLconn()
			brand_id = sql.query("select brand_id from g_categories where id = #{category_id}").fetch_hash['brand_id'].to_i
		sql.close
	
		name =  cgi['name'][0].read
		description = cgi['description'][0].read

		if cgi.has_key? 'new'
			new_val = cgi['new'][0].read
			new = new_val == "on" ? 1 : 0
		else
			new = 0
		end
		Imagefile = cgi['image_file'][0].read
		Thumbfile = cgi['thumbnail_file'][0].read
		
		ImagesDir = DocumentRoot + "/images/models/images/"
		ThumbDir = DocumentRoot + "/images/models/thumbnails/"

		ImagecounterFile = File.new(ImagesDir + "count.txt", "r+")
		ThumbcounterFile = File.new(ThumbDir + "count.txt", "r+")

		newImageFilename = ImagecounterFile.read.strip.to_s.succ
		newThumbFilename = ThumbcounterFile.read.strip.to_s.succ

		ImagecounterFile.close()
		ThumbcounterFile.close()
		
		ImagecounterFile = File.new(ImagesDir + "count.txt", "w") 
		ThumbcounterFile = File.new(ThumbDir + "count.txt", "w") 

		ImagecounterFile.write(newImageFilename)
		ThumbcounterFile.write(newThumbFilename)
		ImagecounterFile.close()
		ThumbcounterFile.close()
		
		i_type, i_width, i_height, i_extension = []
		t_type, t_width, t_height, t_extension = []
		
		image = Image::Info.new Imagefile
		thumb = Image::Info.new Thumbfile
		
		i_type, i_width, i_height, i_extension = image.type, image.width, image.height, image.extension
		t_type, t_width, t_height, t_extension = thumb.type, thumb.width, thumb.height, thumb.extension

		i_path = "/images/models/images/" + newImageFilename + i_extension
		t_path = "/images/models/thumbnails/" + newThumbFilename + t_extension
		
		newImageF