如何自动上传文件 [英] How to Upload a file automatically

查看:116
本文介绍了如何自动上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们浏览要上传的文件时如何自动上传文件?

How to upload file automatically when we browse file to upload?

推荐答案

public void resumeinsert()
    {
        //checking Filename is null or not
        if (fileuploadresume.FileName != "")
        {
            //file storing in folder
            string filePath = Server.MapPath("~/pp/") + fileuploadresume.FileName;
            string ext = Path.GetExtension(fileuploadresume.FileName);

            switch (ext)
            {
                case ".doc":
                    contenttype = "application/vnd.ms-word";
                    break;

                case ".docx":
                    contenttype = "application/vnd.ms-word";
                    break;
            }
            //creating file
            fileuploadresume.SaveAs(filePath);
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            bytes = br.ReadBytes((Int32)fs.Length);
            br.Close();
            fs.Close();
            HttpPostedFile myFile = Request.Files[0];
        }

    }


这篇关于如何自动上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆