NickLarsen kindley solved a problem for me couple of months ago. I should have asked him then so this truly my mistake. If NickLarsen is able to reply, thank for contacting me again, if not then if any one else can tell me the right answer most appericated it. Thanks in advance.
The previous thread is...
unable to upload multiple db images with asp.net mvc
NickLarsen used the following code and I want to know what is and why use the ? in the code. Here is the code...
public ActionResult GetImage(int id, int? imageNum)
{
imageNum = imageNum ?? 0; // here
const string alternativePicturePath = @"/Content/question_mark.jpg";
MemoryStream stream;
SubProductCategory4 z = db.SubProductCategory4.Where(k => k.SubProductCategoryFourID == id).FirstOrDefault();
byte[] imageData = null;
if (z != null)
{
imageData = imageNum == 1 ? z.Image1 : imageNum == 2 ? z.Image2 : imageNum == 3 ? z.Image3 : null; // here
}
if (imageData != null)
{
stream = new MemoryStream(imageData);
}
else
{
var path = Server.MapPath(alternativePicturePath);
stream = new MemoryStream();
var imagex = new System.Drawing.Bitmap(path);
imagex.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Seek(0, SeekOrigin.Begin);
}
return new FileStreamResult(stream, "image/jpg");
}