取消按钮 - 上传

时间:2012-08-25 09:28:14

标签: php jquery uploadify

当我点击取消按钮时,我应该能够从服务器中删除该文件。但它没有被删除。

有人帮忙!

由于

Jquery代码:

$(function() {
    $("#file_upload").uploadify({
        'swf'      : 'uploadify.swf',
        'uploader' : 'uploadify.php',
        'removeCompleted' : false
    });
});

Uploadify.php代码:

$targetFolder = '/uploadify/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'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
}

0 个答案:

没有答案
相关问题