在C#$ _FILES等效 [英] Equivalent of $_FILES in C#

查看:190
本文介绍了在C#$ _FILES等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是PHP的$ _FILES变量在C#中等价?或至少​​一些访问以同样的方式的文件。我有一个上传表单,我无法改变,需要了解如何在这些文件中得到的。

What's the equivalent of PHP's $_FILES variable in C#? Or at least something that accesses the files in the same way. I've got an upload form that I can't change and need to find out how to get at these files.

推荐答案

看看 Request.Files ,例如:

foreach (HttpPostedFile item in Request.Files)
{
    var filename = item.FileName;

    var fileBytes = new byte[item.ContentLength];
    item.InputStream.Read(fileBytes, 0, item.ContentLength);

    // fileBytes now contains the content of the file
    // filename contains the name of the file
}

这篇关于在C#$ _FILES等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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