2012-05-03 83 views
0

我试图做的,实现后的值是:uploadify返回上传

  1. 我想用户的注册过程中上传图片。比方说,我有一个表单接受输入名称和输入文件上传(uploadify按钮)和一个保存按钮。

uploadify.php

$targetFolder = 'uploads'; 
if (!empty($_FILES)) { 
    $tempFile = $_FILES['Filedata']['tmp_name']; 
    $targetPath = $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.'; 
    } 
} 

的Javascript

jQuery('#file_upload').uploadify({ 
     'swf'  : plug+'/uploadify-v3.1/uploadify.swf', 
     'uploader' : plug + '/uploadify-v3.1/uploadify.php' 
     // Put your options here 
    }); 

我会怎么做呢?

回答