使用PHP上传.WMV和.FLV

时间:2012-07-26 12:32:17

标签: php javascript jquery upload

我想使用Uploadify和PHP上传.wmv和.flv文件。但是,我似乎无法做对。

这是我的代码:

$(function() {
    $("#file_upload").uploadify({
        'swf'         : 'uploadify/uploadify.swf',
        'uploader'    : 'uploadify/uploadify.php',
        'uploadLimit' : 1,
        'folder'    : 'uploads',
        'method'   : 'post',
        'auto'      : true,
        'multi'     : true,
        'fileExt'   : '*.jpg; *.gif; *.png; *.jpeg; *.wmv; *.flv',
         'onUploadSuccess' : function(file, data, response) {
        alert('The file was saved to: ' + file);
             } 
    });
});

Uplodify.php

$targetFolder = '/uploads'; // Relative to the root

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png','wmv'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

        move_uploaded_file($tempFile,$targetFile);
}

关于我做错了什么的任何想法?

1 个答案:

答案 0 :(得分:1)

如果读取http://css-tricks.com/snippets/php/increase-maximum-php-upload-size/

,您可能只需要增加最大上传限制