douyan8772 2012-03-28 13:54
浏览 63

使用php GET数据为uploadify创建动态上传路径

I am writing an intranet customer manager (so will not be accessible at all from the internet, and runs locally only). I am using Uploadify http://www.uploadify.com/documentation/ , a Jquery script to add files to each of the customers records (its being used in a shop, so the shop keeper can add photos / measurement info for the customers carpets).

I am using the following settings in the head of my index.php to call the jquery uploader. What I cant work out is how to add a dynamic upload folder to it ?. What it needs to do is be :

'folder'    : './customer-files/<?php $_GET['cfid'] ?>',

Is it even possible to mix jquery and php like this ?, what its supposed to do is replace the cfid stored in GET with the actual id number of the customer, for example ./customer-files/22

<script type="text/javascript" src="./uploadify/swfobject.js"></script>
<script type="text/javascript" src="./uploadify/jquery.uploadify.v2.1.4.min.js">   </script>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
  $('#customeraddnewfile').uploadify({
    'uploader'  : './uploadify/uploadify.swf',
    'script'    : './uploadify/uploadify.php',
    'cancelImg' : './uploadify/cancel.png',
    'folder'    : './customer-files',
   'auto'      : true
  });
});
// ]]>
</script>
  • 写回答

2条回答 默认 最新

  • duanjiu1894 2012-03-28 14:07
    关注

    Best way to do this is to pass through an extra parameter using scriptData (your customer ID, and probably some kind of security token that you can check) and then edit the PHP script to lookup the user, create a folder if it doesn't exist yet, then upload the file to that location. Bypassing the need to use the folder attribute.

    <script type="text/javascript">
    // <![CDATA[
    $(document).ready(function() {
      $('#customeraddnewfile').uploadify({
        'uploader'  : './uploadify/uploadify.swf',
        'script'    : './uploadify/uploadify.php',
        'cancelImg' : './uploadify/cancel.png',
        'folder'    : './customer-files',
        'scriptData': {'cust_id':1234},
        'auto'      : true
      });
    });
    // ]]>
    </script>
    

    Without your PHP script I can't really help in more detailed terms.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大