dt3999 2011-09-08 11:47
浏览 60

我无法使用Cake PHP中的jQuery Uploadify开始上传文件

I've included the js and css files, in the frontend all is loaded correctly, but when I click on

<a href="javascript:$('#file_upload').uploadifyUpload();"> Upload </a>

nothing happens, not receiving any error in firebug.

Basically, I can't upload files. Even if the uploadify option "auto" is set to "true".

How to repair this? What can be wrong?

My code:

<script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/jquery.imgareaselect.min.js"></script>

    <script type="text/javascript" src="/js/jquery.fancybox.pack.js"></script>
    <script type="text/javascript" src="/js/uploadify/swfobject.js"></script>
    <script type="text/javascript" src="/js/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
    $("a.group").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600,
        'speedOut'      :   200,
        'width': 500,
        'height' : 400,
        'overlayShow'   :   false
    });
});

//]]>
</script>
    <script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    $("#file_upload").uploadify({
        "uploader": "/js/uploadify/uploadify.swf",
        "script": "/uploadify/upload",
        "cancelImg": "/img/uploadify/cancel.png",
        "scriptData": {'type': 1},
        'removeCompleted' : true,
        'folder': '/uploads',
        "auto": true,
        "multi": false,
        "onComplete": function(event, ID, fileObj, response, data) {

        },
        'onError': function (event, ID, fileObj, errorObj) {
            alert(errorObj.type + ' Error: ' + errorObj.info);
        }
    }); 
});
</script>


<input type="file" id="file_upload" name="file_upload" />

<a href="javascript:$('#file_upload').uploadifyUpload();">Upload</a>

Thanks

  • 写回答

4条回答 默认 最新

  • douxiong5438 2011-09-08 11:51
    关注

    Shouldn't that be the onclick event?

    <a href="#" onclick="javascript:$('#file_upload').uploadifyUpload();"> Upload </a>
    

    If auto is set to true the files should upload automatically as soon as they are selected so you don't even need an upload link/button. Just put this inside your document ready function.

    $("#file_upload").uploadify({
        'uploader'  : '/js/uploadify/uploadify.swf',
        'script'    : '/js/uploadify/uploadify.php',
        'cancelImg' : '/js/uploadify/cancel.png',
        'folder'    : '/some_folder',
        'fileExt'   : '*.jpg;*.jpeg;*.gif;*.png',
        'auto'      : true});
    
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能