开发者

Uploadify stuck at 100% but still does the upload

I seem to have a problem with uploadify. It always get stuck at 100% on the first file, no matter what the file is. I am using Zend on my Wamp and it works fine there but as soon as I upload it on my linux server it gets stuck. The file is uploaded and renamed but it never fires the onComplete event and stays at 100% on the first file. Here is my javascript:

$('#fileInput').uploadify({
        'uploader'          : 'http://test.thev开发者_开发技巧enuelist.co.uk/js/uploadify/uploadify.swf',
        'script'            : 'http://test.thevenuelist.co.uk/ajax/uploadify',
        'cancelImg'         : 'http://test.thevenuelist.co.uk/js/uploadify/cancel.png',
        'folder'        : '/userdata/images/',
        'auto'              : true,
        'multi'         : true,
        'fileDesc'      : 'Image Files (*.jpg;*.jpeg;*.gif;*.png)',
        'fileExt'       : '*.jpg;*.jpeg;*.gif;*.png', 
        'buttonText'        : 'Upload Images',
        'removeCompleted'   : true,
        'onComplete'            : function (event, queueID, fileObj, response, data) {
            var answer = eval('(' + response + ')');
            if(answer.result == "success")
            {
                $("#hdnImages").val($("#hdnImages").val() + answer.fileName + ",");
                var toAdd = "<li><img src='/images/delete.png' id='removeItem' rel='"+answer.fileName+"' style='cursor:pointer;' title='Remove' alt='Remove'/>&nbsp;&nbsp;Image "+answer.realName+" uploaded</li>";
                $("#completedItemsList").append(toAdd);
            }
        },
        'onError': function (event, queueID ,fileObj, errorObj) {
            alert(errorObj.info);
        }
    });

And here is my Zend code behind:

$tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT']. '/' . $_REQUEST['folder'] . '/';
    $fileNameArray = explode('.',$_FILES['Filedata']['name']);
    $hash = substr(md5(microtime()),0,5);
    $finalFileName = $fileNameArray[0].$hash.'.'.$fileNameArray[1];
    $targetFile =  str_replace('//','/',$targetPath) . $finalFileName;

    if(move_uploaded_file($tempFile,$targetFile))
    {
        $data = array("result"=>"success","fileName"=>$finalFileName,"realName"=>$_FILES['Filedata']['name']);
    }
    else
    {
        $data = array("result"=>"failed");
    }

    echo Zend_Json::encode($data);

Any help would be greatly appreciated. I have spent way too much time trying to figure it out. I need my onComplete event to work so I can finish my forms.


I found with uploadify I had to return either a 1 or a 0 for success or failure to get it to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜