uploadify未在switch/if-else语句中上传


uploadify not uploading in switch / if - else statement

我一直在使用Uploadify插件上传文件。基本上,我需要上传不同类型的文件(照片,平面图,宣传册)

所以,下面是我的上传代码(上传表单)

<? $sid = session_id();  ?>
$(document).ready(function() {
    $('#file_upload').uploadify({
        'uploader'  : 'js/uploadify214/uploadify.swf',
        'script'    : 'uploader.php?pid=<? echo $pid; ?>&type=<? echo $type; ?>',
        'scriptData': {'session': '<? echo $sid; ?>'},
        'multi': true, // enable multiple upload
        'queueSizeLimit': 5, // number of file at once
        'onQueueFull': function(event, queueSizeLimit) {
            alert("You can only upload " + queueSizeLimit + " files at once");
            return false;
        },
        'cancelImg' : 'js/uploadify214/cancel.png',
        'auto'      : false,
        'onAllComplete' : function(event,data) {
              window.location = "files.php?pid=<? echo $pid; ?>" // redirect to previous page
        }
    });
});

所有上传将由uploader.php处理下面是代码

session_id($_REQUEST['session']);
require_once('function.php');
$pid = $_REQUEST['pid'];
$type = $_REQUEST['type'];
$photo_file = $_FILES['Filedata'];
$photo_tags = 'test';
$status = '1';
$inuse = 0;
// the function will run if i put it here
property_photo_upload($user_id, $pid, $photo_file, $photo_tags, $inuse, 'photo');
// but if i put it in switch / if-else statement, the code will not run
switch($type){
    case 'photo' :
        property_photo_upload($user_id, $pid, $photo_file, $photo_tags, $inuse, 'photo');
        break;
    case 'floorplan' :
        property_doc_upload($user_id, $pid, $photo_file, $photo_tags, $inuse, 'floorplan');
        break;
    case 'brochure' :
        property_doc_upload($user_id, $pid, $photo_file, $photo_tags, $inuse, 'brochure');
        break;
}

所以,问题是,如果我把上传函数OUTSIDE/WITH放在开关/if-else语句之外,上传进度可以毫无问题地运行。但当我把函数放在switch/if-else语句中时,上传突然不起作用了。

我需要switch语句,这样我的代码就可以处理不同文件类型的上传。

非常感谢您的帮助。抱歉我英语不好,问题太长。提前感谢

主要原因是$type的变量。

什么类型的$type?

调用var_dump 的函数