"problem in line:img.save(directory+filename);"
In which case, I would suspect the problem is either the line above:
string directory = Server.MapPath("./all_images/foroshgahImages/");
Which may be returning an invalid path, or that the directory write permissions are not set correctly. Check the
directory
value before you save the file.
Look and see if you get any useful information in the exception and inner exception by enclosing it in a try / catch - that may help isolate it.