dtotwai720621 2010-08-25 09:17
浏览 34
已采纳

Flash和会话

First of all, I'm using KohanaPHP Framework.

I've impletemented SWFUpload successfully, working quite nice. I'm having only one issue.

The main problem is I need to allow users to upload attachments before submitting form. So I decided to use Session var to store attachments array. Unfortunately, it is working inly if I use HTML upload (based on iframe), but not when I use SWFUpload.

I tried to Google for that, but without any working solution. Any ideas?

Update & Solution
Basically, I didn't know there's an issue with Flash and sessions. Providing the same session id didn't helped me because I got unlogged. Anyway I got a solution for people with the same issue.

I created an unique ID of an item. I upload files to temporary directory, then... I'm scanning this directory and I'm adding uploaded filenames to session.

Tom

  • 写回答

1条回答 默认 最新

  • duandi8852752 2010-08-25 09:26
    关注

    What you need to is pass the session id to SWFUpload by hand. In a nutshell, you do this in your template:

    <script type="text/javascript">
    var PHPSESSID = <?php echo json_encode(session_id()); ?>;
    </script>
    

    Then you do this with your SWFUpload code:

    var settings = {
       post_params: {"PHPSESSID" : PHPSESSID},
       /* the rest of the settings */
    };
    

    And finally, in your application code, before you call session_start, you need to do this (usually just in your index.php or whatever bootstrap you use):

    // Restore session that came from SWFUpload
    if(isset($_REQUEST['PHPSESSID']))
        session_id($_REQUEST['PHPSESSID']);
    

    After this session_start() will use the correct session even for SWFUpload requests.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条