My guess is there is no file. You need to check if a file was uploaded, only then access the PostedFile property. Modify your code like this:
if(PhotoUpload.HasFile)
{
int fileLength1 = PhotoUpload.PostedFile.ContentLength;
byte[] imageBytes = new byte[fileLength1];
PhotoUpload.PostedFile.InputStream.Read(imageBytes, 0, fileLength1);
}