- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用多重上传,但在我的 MVC 操作中,我没有获得上传文件的列表,而是获得每个上传项目的文件 []。
我正在上传 2 个文件,但是当我通过以下方式在我的 Controller 中访问它时:
foreach (string filename in Request.Files)
{
var file = Request.Files[filename];
//file.name always reads from file[] and picks the first file in all requests
}
我的完整请求是:
Request URL: http://localhost:54434/1328/uploads/new
Request Method:POST
Status Code:201 Created
Request Headersview source
Accept:application/json
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:8957136
Content-Type:multipart/form-data; boundary=----WebKitFormBoundarysX8tBB9TH4BzWZsG
Cookie:glimpsePolicy=On; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1; glimpseId=Chrome 28.0; __RequestVerificationToken=itQ6HqqB_D7H_Y924w-HFfF8tq
ASP.NET_SessionId=cnj4lzpunuxnbyunl1m5gtpn
Glimpse-Parent-RequestID:04a1b6d2-6c6a-4da0-936d-3ff39e5b8c6c
Host:localhost:54434
Origin:http://localhost:54434
Referer:http://localhost:54434/1328/uploads/new
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
X-Requested-With:XMLHttpRequest
Request Payload
------WebKitFormBoundarysX8tBB9TH4BzWZsG
Content-Disposition: form-data; name="__RequestVerificationToken"
dmPL-YRqsiwjKy43rlkYIBJE4kPlthsyL0IgnyHbtrD7Doczpbu9Z1SYeoL_93vuR15-6HfpNCCEzkzLYHBIxFJOQd3ynRGGYqILGpMWdLE1
------WebKitFormBoundarysX8tBB9TH4BzWZsG
Content-Disposition: form-data; name="private_upload"
true
------WebKitFormBoundarysX8tBB9TH4BzWZsG
Content-Disposition: form-data; name="files[]"; filename="Maid with the Flaxen Hair.mp3"
Content-Type: audio/mp3
------WebKitFormBoundarysX8tBB9TH4BzWZsG
Content-Disposition: form-data; name="files[]"; filename="Sleep Away.mp3"
Content-Type: audio/mp3
------WebKitFormBoundarysX8tBB9TH4BzWZsG--
Response Headersview source
Cache-Control:private, s-maxage=0
Content-Encoding:gzip
Content-Length:57
Content-Type:application/json; charset=utf-8
Date:Fri, 16 Aug 2013 10:55:23 GMT
Server:Microsoft-IIS/8.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:4.0
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcUHJvamVjdHNcU3VydmVudHJpeFxhcHBcU3VydmVudHJpeFxGYXN0U3VydmV5b3JzXDEzMjhcdXBsb2Fkc1xuZXc=?=
````
Dropzone 配置是:
<script type="text/javascript">
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("form#my-awesome-dropzone", {
paramName: "files", // The name that will be used to transfer the file
autoProcessQueue: false,
forceFallback: false,
uploadMultiple: true,
maxFilesize: 10,
previewsContainer: ".dropzone-previews",
clickable: ".dropzone" //make only this region clickable
});
myDropzone.on("addedfile", function (file) {
/* Maybe display some more file information on your page */
console.debug("added a file: " + file.name);
});
myDropzone.on("success", function (file) {
$("#drop-success").show();
});
$("#btnDropzone").click(function () {
myDropzone.processQueue();
});
});
</script>
最佳答案
如果输入名称 file[]
确实是问题所在,那么您可以将 Dropzone 选项 uploadMultiple
设置为 false。这将创建多个请求并单独发送每个文件,而不是在一个请求中发送所有并行上传的文件。
关于asp.net-mvc - dropzonejs 多文件上传无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18272703/
我正在构建一个 AngularJs 应用程序,我正在使用 DropzoneJs 的 dropzone。我需要使用成功和错误回调,因为我必须访问服务器响应。我遇到一个问题,如果我使用回调,preview
我正在对 dropzonejs 图像 uploader 进行一些修改。我希望最多允许上传 12 张图片。我看到了 maxFiles 的配置,但将其设置为 12 后,它仍然允许添加文件并生成缩略图预览。
我在显示缩略图上的“删除”按钮时遇到问题。 var myDropzone = new Dropzone("#my-awesome-dropzone"); myDropzone.opti
我正在使用dropzonejs用于简单的文件上传。不过,我目前遇到了一些问题。 我不知道如何限制上传的文件类型。我的 PHP 后端有文件验证,但文件似乎已上传(它们有一个复选标记),即使它们没有通过这
我已设置 dropzone 并使用我的 AWS S3 帐户。不过,我希望能够在将文件发送到 S3 之前对其进行重命名(例如附加时间戳),以便与现有文件同名上传的文件不会被覆盖。我尝试在发送事件中捕获此
我正在使用 dropzonejs 上传和删除服务器上的多个图像。上传多张图片工作正常但一次删除一张图片给我带来了问题。单击删除链接时,所有与图像关联的 ajax 函数都会同时触发,这会导致删除所有文件
我尝试通过 dropzone 搜索让我的上传功能与我自己的自定义表单一起使用。不幸的是,stackoverflow 和其他方面的其他线程对我帮助不大。所以也许任何人都可以了解真正的基础知识并帮助我理解
我正在使用 Dropzonejs 来处理文件上传。我有一个很大的表格,文件只是其中的一部分。我已将 dropzone 附加到表单内的 div,但文件附加到正文的末尾。有没有办法将文件放入表单中,以便它
有没有什么办法可以不使用Form而使用Dropzone js。我想像下面这样使用。但是这样就不会显示图像预览。 最佳答案 在 docs
我正在使用 Dropzonejs 上传文件以在我的模块中使用。它的工作方式是编辑项目,将文件拖到放置区,放置区隐藏,然后您会看到图像的预览。该预览是自制的,并且有一个删除按钮来删除图像并取消数据库中的
我正在制作一个上传脚本,但我坚持从“addfile”事件的“file”获取dataURL,这是我的代码: $(function() { var dropzone = new Dropzone(
问题 我正在使用 dropzone 处理多个图像上传。我希望它生成 280x280px 的缩略图。尽管我尽了最大的努力,它还是会不断生成 100x100 像素的缩略图。 代码 这是我的代码: D
我正在使用 dropzonejs 删除文件,然后上传到服务器。我想实现当视频文件被删除时,它应该能够使用html5视频播放。这是我尝试过的地方, this.on("addedfile"
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 5 年前。 Improve this ques
我在我的网站上使用 dropzone js,我想访问插件使用的拖放照片源。这就是我的意思:在 added file 事件监听器中,我可以轻松访问已删除文件的名称,例如 dropzoneForm.on(
我试图使用选项 maxFiles: 1; 将用户可以选择的文件数量限制为一个;然而,这也阻止用户上传第二个、第三个等文件,这正是我想要的。我希望只选择一个文件并允许后续上传。这可能吗? 这是我的代码:
我使用插件dropzonejs.com 。现在我在html文档中编写这段代码 link('task', 'upload'); ?>" id="pinupload" class="dropzone" s
我在表单中使用 dropzoneJS。除了图像之外,表单还记录用户输入。一切正常。用户输入将进入我的数据库,图像将上传到定义的目录中。现在我想将拖放图像字段设置为可选字段,用户可以选择上传图像或将其留
我正在使用 dropzone js 将文件上传到服务器。我的服务器位于 Tornado 中,但 dropzonejs 在 header 中发送了一个选项请求,尽管我将其设置为执行方法 Post。 问题
我有一个上传视频的表格,视频的持续时间/长度很重要。 在我用 PHP 上传文件后,我用 FFMpeg 检查视频文件大小的持续时间。 我用 PHP 计算持续时间,需要通过 PHP 以某种方式发送持续时间
我是一名优秀的程序员,十分优秀!