If you're using same thing in your program more then twice then you should use Function there to reduce code and more clear understanding.
likewise you're using same thing to check the extension of uploaded file, you could use function in space, see following.
public bool ShouldUpload(string filename)
{
if(filename.EndsWith(".jpg") || filename.EndsWith(".png"))
return true;
}
if(ShouldUpload(Fileupload1.postedfile.filename))
{
}