将文件路径从Flash传递到JavaScript以便上传? [英] Passing file paths from Flash to JavaScript for upload?

查看:173
本文介绍了将文件路径从Flash传递到JavaScript以便上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我的问题:是否有可能从正在运行的Flash应用程序传递文件名,这个应用程序的目的只是为了启用多个文件选择,将一个JavaScript应用程序传递给一个处理所有文件上传到服务器的JavaScript应用程序?



我已经研究了各种Flash上​​传解决方案(如SWFUpload,Uploadify等),而且它们都不符合我的需求。我想要一个容易实现的解决方案(如Uploadify),这也让我指定HTTP请求的各个部分。



我需要这个的原因是因为我的上传表单使用会话cookie(用于用户认证)和CSRF令牌都在上传文件时传递给服务器。



技术上是否可以将文件名(+路径)传递给JavaScript应用程序,然后处理上载?

谢谢,
FMD

解决方案

我很抱歉,但是不行,不能将文件名从Flash传递到JavaScript, ,您可以将会话ID传递给Flash。



如果您正在使用PHP(我不是说你是服务器端语言可能具有类似的功能)可以重新建立会话:

  session_id($ _ POST ['ses']); 
session_start();

您无法将文件名传递给JavaScript,或者通过第一个地方)是这将是一个重大的安全问题,考虑以下几点:$ b​​
$ b $ pre $ var $ uploader = document.getElementById('id_of_input_type_file );
uploader.value ='c:\Users\Administrator\Documents\commonBankKeyFile.ebjkeystore';
document.getElementById('formId')。submit();

...然后你去了,我只是通过你访问我的页面获得了你的银行凭证,不需要钓鱼。


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?

I have examined various Flash upload solutions (like SWFUpload, Uploadify, etc.) and none of them meets my needs. I want an easy to implement solution (like Uploadify) which also lets me specify various parts of the HTTP request.

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.

Is it technically possible to pass filenames (+ paths) to a JavaScript application which then handles the upload?

Thank you, 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.

If you are using PHP (I'm not saying you are, your server side language might have similar functions), you could reestablish the session:

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:

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.

这篇关于将文件路径从Flash传递到JavaScript以便上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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