//assuming there is image file apple.png or jpg in the resource folder
Texture2D tex = Resources.Load(apple) as Texture2D;
if(tex == null)
Debug.LogError("Error loading image");
else
Debug.Log ("Scuccess in loading image");
cube.renderer.material.mainTexture = tex;