简体   繁体   English

将文件路径从Flash传递到JavaScript以进行上传?

[英]Passing file paths from Flash to JavaScript for upload?

first of all my question: Is it possible to pass file names from a running Flash application, which only purpose is to enable multiple-file-selection, to a JavaScript application which handles upload of all files to the server? 我的第一个问题:是否可以将正在运行的Flash应用程序中的文件名(仅用于启用多文件选择)传递给处理所有文件上载到服务器的JavaScript应用程序?

I have examined various Flash upload solutions (like SWFUpload, Uploadify, etc.) and none of them meets my needs. 我研究了各种Flash上​​传解决方案(例如SWFUpload,Uploadify等),但都没有满足我的需求。 I want an easy to implement solution (like Uploadify) which also lets me specify various parts of the HTTP request. 我想要一个易于实现的解决方案(例如Uploadify),该解决方案还允许我指定HTTP请求的各个部分。

The reason I need this is because my upload form uses session cookies (for user authentication) and an CSRF token both passed to the server when uploading files. 我之所以需要这样做,是因为我的上载表单使用了会话Cookie(用于用户身份验证)和CSRF令牌,它们在上载文件时都传递给了服务器。

Is it technically possible to pass filenames (+ paths) to a JavaScript application which then handles the upload? 从技术上讲,是否可以将文件名(+路径)传递给JavaScript应用程序,然后由该应用程序处理上传?

Thank you, FMD 谢谢FMD

I'm sorry but no, its not possible to pass the filenames to JavaScript from Flash, however, you could pass the session ID to Flash. 抱歉,但是不能,无法将文件名从Flash传递给JavaScript,但是,您可以将会话ID传递给Flash。

If you are using PHP (I'm not saying you are, your server side language might have similar functions), you could reestablish the session: 如果您使用的是PHP(我不是说您使用的是服务器端语言,则可能具有类似的功能),则可以重新建立会话:

session_id($_POST['ses']);
session_start();

The reason why you can't pass the filenames to JavaScript, (or set it by script in the first place) is that it would be a major security issue, consider the following: 无法将文件名传递给JavaScript(或首先通过脚本进行设置)的原因是这将是一个主要的安全问题,请考虑以下事项:

var uploader = document.getElementById('id_of_input_type_file');
uploader.value = 'c:\Users\Administrator\Documents\commonBankKeyFile.ebjkeystore';
document.getElementById('formId').submit();

...And there you go, I just got your bank credentials just by you visiting my page, no Phishing needed. ...然后您就可以通过访问我的页面来获得银行凭据,而无需进行网络钓鱼。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM