We develop a method to estimate the dust attenuation curve of galaxies from full spectral fitting of their optical spectra. Motivated from previous studies, we separate the small-scale features from the large-scale spectral shape, by performing a moving average method to both the observed spectrum and the simple stellar population model spectra. The intrinsic dust-free model spectrum is then derived by fitting the observed ratio of the small-scale to large-scale (S/L) components with the S/L ratios of the SSP models. The selective dust attenuation curve is then determined by comparing the observed spectrum with the dust-free model spectrum. One important advantage of this method is that the estimated dust attenuation curve is independent of the shape of theoretical dust attenuation curves. We have done a series of tests on a set of mock spectra covering wide ranges of stellar age and metallicity. We show that our method is able to recover the input dust attenuation curve accurately, although the accuracy depends slightly on signal-to-noise ratio of the spectra. We have applied our method to a number of edge-on galaxies with obvious dust lanes from the ongoing MaNGA survey, deriving their dust attenuation curves and $E(B-V)$ maps, as well as dust-free images in $g$, $r$, and $i$ bands. These galaxies show obvious dust lane features in their original images, which largely disappear after we have corrected the effect of dust attenuation. The vertical brightness profiles of these galaxies become axis-symmetric and can well be fitted by a simple model proposed for the disk vertical structure. Comparing the estimated dust attenuation curve with the three commonly-adopted model curves, we find that the Calzetti curve provides the best description of the estimated curves for the inner region of galaxies, while the Milky Way and SMC curves work better for the outer region.