| |

VerySource

 Forgot password?
 Register
Search
View: 1443|Reply: 14

Urgent question about multi-file upload

[Copy link]

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-15 15:30:01
| Show all posts |Read mode
protected void Button1_Click (object sender, EventArgs e)
    {
        HttpFileCollection files = Request.Files;
        for (int i = 0; i <files.Count; i ++)
        {
            HttpPostedFile postedfile = files [i];
            String filename = Path.GetFileName (postedfile.FileName);
            postedfile.SaveAs (@ "D:\fileload\" + filename);
        }
    }
Why can I upload when the motherboard is not used, but not when using the motherboard?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-15 16:45:01
| Show all posts
probably not/
The only difference between a page that uses a motherboard page and a normal page is that the level of the control is lowered by one level, and the rest are the same.
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-15 18:30:01
| Show all posts
So I wondered
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-15 21:15:01
| Show all posts
What is wrong?
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-16 10:15:01
| Show all posts
No error reported, it is HttpFileCollection files = Request.Files; after files.count = 0
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-16 14:15:01
| Show all posts
I also tried it on the motherboard page without this problem.
What controls do you use?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-16 15:15:01
| Show all posts
I tried both controls, no problem.
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-16 16:30:02
| Show all posts
input file
Reply

Use magic Report

2

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

 Author| Post time: 2020-4-25 11:30:01
| Show all posts
I use JS to press the button to add the file domain
<script language = "JavaScript">
    function addFile ()
    {
    var str = '<INPUT type = "file" size = "30" NAME = "File">' + "<br/>";
    document.getElementById ('MyFile'). insertAdjacentHTML ("beforeEnd", str);
    }
    </ script>
But when uploading
 HttpFileCollection files = Request.Files;
        for (int i = 0; i <files.Count; i ++)
        {
            HttpPostedFile postedfile = files [i];
            String filename = Path.GetFileName (postedfile.FileName);
            postedfile.SaveAs (@ "D:\fileload\" + filename);
        }
The files.count here is always equal to 0, but can it be uploaded normally without the motherboard? ? ? ?
Expert advice, is it related to the mother board? ?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 00:45:01
| Show all posts
You are adding a file control on the client, no wonder.

The control added by the client, even if you don't use the motherboard page, you should not get the Count of Request.Files
Note that there is a 'MyFile' that seems to exist.
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