Mg-doped (≤15at%) ZnO thin films were prepared on quartz glass substrates by sol-gel method using a spinning-techniques. The films were charactered by X-ray diffraction , UV Vis-NIR double beam spectrophotometer and a SHIMADZU fluorespectrometer. It was found that optimally crystallized when the Mg concentration is 9at% were obtained. A photoluminescence study at room temperature revealed a blue shift in the near band edge emission peak with increasing of Mg content , which is agreement with the observation from the optical transmittance measurement. The photoconductive UV detectors based on these films were investigated, and the result showed that highest response was obtained from the photodecters fabricated by films with 15at% Mg concentration.