Uploading using Input=file

Source: Internet
Author: User

foreground, the target of the form points to the IFRAME

            <form action= "/emailhandler.ashx?action=upload" id= "Form1" Name= "Form1" enctype= "Multipart/form-data" method= " Post "target=" Hidden_frame ">                <div class=" Up_file "id=" Up_file ">                    <input type=" file "class=" fl  h_20 w_300 "id=" file "multiple=multiple name=" upload "onchange=" fileselected () "/>                    <input type=" Submit "value=" Upload "/>                </div>                <iframe name= ' hidden_frame ' id=" hidden_frame "style= ' Display:none ' > </iframe>                <div id= "FileInfo" ></div>            </form>
// Post-Upload callback method        function Callback (msg) {            document.getElementById ("file"). outerHTML = document.getElementById ("file"). outerhtml;            $ (' #attr_url '). Val (msg);            document.getElementById (' FileInfo '). InnerHTML + = "<p> upload success </p>"        }

Background:

 Case "Upload":                    #regionUploading files                    {                        stringPath =""; if(Context. Request.Files.Count >0) {httpfilecollection files= Context. Request.Files;//Accept File                            if(Files. Count >0)                            {                                foreach(stringIinchfiles) {Httppostedfile file=Files[i]; stringFileName = path.getfilename (file. FileName);//Get file name                                    stringFileext = Path.getextension (fileName);//Get file Type                                    if(! Directory.Exists (context. Server.MapPath ("/emailfiles/")) {directory.createdirectory (context. Server.MapPath ("/emailfiles/")); }                                                                        stringDircstr ="/emailfiles/"+ Emp.uid +"/"; if(!directory.exists (context. Server.MapPath (DIRCSTR)) {Directory.createdire Ctory (Path.getdirectoryname) (context.                                    Server.MapPath (DIRCSTR)); }                                    stringName =dircstr+ datetime.now.year+"-"+datetime.now.month+"/"; if(!directory.exists (context. Server.MapPath (name))) {Directory.createdirecto Ry (Path.getdirectoryname) (context.                                    Server.MapPath (name))); }                                    stringFileloadname = name +datetime.now.day.tostring () +datetime.now.hour.tostring () +datetime.now.minute.tostring () + DateTime.Now.Second.ToString () +Fileext; File. SaveAs (context.                                    Server.MapPath (Fileloadname)); Path+ = Fileloadname +','; }} Path= path. TrimEnd (','); Context. Response.Write ("<script>parent.callback ('"+ Path +"') </script>");//Call the foreground callback method} Break; }                    #endregion

Uploading using Input=file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.