当 enctype = multipart/form-data 时php://input没数据。
//文件写入流private void ReadFile()
{
Byte[] MesageFile
string path =@"c:\123.XML"
FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)
int size = Convert.ToInt32(stream.Length)
MesageFile = new Byte[size]
stream.Read(MesageFile, 0, size)
stream.Close()
string fileName =path.Substring(path.LastIndexOf("\\") + 1, path.Length path.LastIndexOf("\\") - 1)
WriteFile(MesageFile, fileName)
}
//写入文件
private void WriteFile(Byte[] fileByte,string fileName)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "\\UpLoad\\" + DateTime.Now.ToString("yyyy-MM-dd")+"\\"
if (!Directory.Exists(path))
Directory.CreateDirectory(path)
string savepath = path + fileName
FileStream fos = new FileStream(savepath, FileMode.OpenOrCreate, FileAccess.ReadWrite)
fos.Write(MesageFile, 0, MesageFile.Length)
fos.Close()
}
上传的文件格式不限。
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)