| |

VerySource

 Forgot password?
 Register
Search
View: 648|Reply: 1

After downloading this page

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-4 17:30:01
| Show all posts |Read mode
I read everyone's code about downloading, and went back and tried it. It can be successfully downloaded without tools. But the file downloaded with Thunder is this page. The following is the code, hope to advise !!!

      
       string name = ("Doc2\\") + "Employees.xml";
      FileInfo aFile = new FileInfo (Server.MapPath (name));
      
        string na = Path.GetFileName (name);
        string hz = "." + name.Substring (name.LastIndexOf (".") + 1); // Get the suffix of the file
       // Clear everything in the buffer stream
        Response.Clear ();
        Response.ClearHeaders ();
        Response.BufferOutput = false;
        Response.ContentType = "application / octet-stream";
         Response.AppendHeader ("Content- disposition", "attachment; filename =" + HttpUtility.UrlEncode ("baocun" + hz, Encoding.UTF8));
        Response.AppendHeader ("Content-Length", aFile.Length.ToString ());
        Response.WriteFile (aFile.FullName);
      
               Response.End ();
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-6 19:45:01
| Show all posts
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
  Set fl = fso.getfile (url)
  flsize = fl.size
  flName = fl.name
  Set fl = Nothing
  Set fso = Nothing
  Set objStream = Server.CreateObject ("ADODB.Stream")
  objStream.Open
  objStream.Type = 1
  objStream.LoadFromFile url
  Select Case lcase (Right (flName, 4))
    Case ".asf"
      ContentType = "video / x-ms-asf"
    Case ".avi"
      ContentType = "video / avi"
    Case ".doc"
      ContentType = "application / msword"
    Case ".zip"
      ContentType = "application / zip"
    Case ".xls"
      ContentType = "application / vnd.ms-excel"
    Case ".gif"
      ContentType = "image / gif"
    Case ".jpg", "jpeg"
      ContentType = "image / jpeg"
    Case ".wav"
      ContentType = "audio / wav"
    Case ".mp3"
      ContentType = "audio / mpeg3"
    Case ".mpg", "mpeg"
      ContentType = "video / mpeg"
    Case ".rtf"
      ContentType = "application / rtf"
    Case ".htm", "html"
      ContentType = "text / html"
    Case ".txt"
      ContentType = "text / plain"
    Case Else
      ContentType = "application / octet-stream"
    End Select
    Response.AddHeader "Content-Disposition", "attachment; filename ="&flName
    Response.AddHeader "Content-Length", flsize
 
    Response.Charset = "UTF-8"
    Response.ContentType = ContentType
 
    Response.BinaryWrite objStream.Read
    Response.Flush
    response.Clear ()
    objStream.Close
    Set objStream = Nothing
Try this
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list