2014-03-06 2 views
0

jQuery 다중 파일 업로드 플러그인 v1.48의 파일 업로드 이름을 표시하는 방법은 무엇입니까?jQuery 다중 파일 업로드 플러그인의 파일 업로드 이름을 표시하는 방법

사용자가 파일을 업로드 한 후 프로필 아래에 업로드 한 파일을 표시 할 수있는 방법이 있습니까?

1.if (isset($_FILES['tb-documents'])) {   
    $documents = $_FILES['tb-documents']; 
    foreach ($documents['name'] as $key => $value) { 
    if ($documents['name'][$key]) { 
    $document = array(
    'name' => $documents['name'][$key], 
    'type' => $documents['type'][$key], 
    'tmp_name' => $documents['tmp_name'][$key], 
    'error' => $documents['error'][$key], 
    'size' => $documents['size'][$key]  
    ); 
     $status = wp_handle_upload($document, array('test_form' => false)); 

    if(!isset($status['error'])) { 
    $uploads = wp_upload_dir(); 
    add_user_meta($user->ID, 'tb-documents', $uploads['url'].'/'.basename($status['file'])); 
    }     
    } 

    } 
} 

업로드가 사용자 프로필에서 제대로 작동합니다. 그러나 업로드 한 파일 이름을 찾아서 업로드 된 모든 파일 이름을 표시하고 싶습니다.

어떤 변수를 사용해야합니까?

1.I tried this, $content .= '.$documents['name']'; but it doesn't work. It shows syntax error. 

답변

0

이 결과는 $documents['name'][$key]에서 결합하여 사용자에게 보여줘야합니다. 당신은 업 로더에 업로드 된 파일을 표시하려면

if (isset($_FILES['tb-documents'])) { 
    $uploadedFiles = array(); 
    $documents = $_FILES['tb-documents']; 
    foreach ($documents['name'] as $key => $value) { 
     if ($documents['name'][$key]) { 
      $document = array(
        'name' => $documents['name'][$key], 
        'type' => $documents['type'][$key], 
        'tmp_name' => $documents['tmp_name'][$key], 
        'error' => $documents['error'][$key], 
        'size' => $documents['size'][$key] 
      ); 
      $status = wp_handle_upload($document, array('test_form' => false)); 

      if (!isset($status['error'])) { 
       $uploads = wp_upload_dir(); 
       add_user_meta($user->ID, 'tb-documents', $uploads['url'] . '/' . basename($status['file'])); 
       $uploadedFiles[] = $documents['name'][$key]; 
      } 
     } 
    } 

    var_dump(implode(", ", $uploadedFiles)); 
} 
+0

안녕하세요, 파일 이름을 가져 오기 위해 어떤 변수를 사용해야합니까? $ content. = '
Download Document #' . ($y+1) . ''; } 이것은 사용중인 코드이지만 텍스트 링크를 다운로드 문서로 표시합니다. 고정 된 다운로드 문서를 실제 파일 이름을 나타내는 텍스트로 변경하는 방법이 있습니까? – user2987446

+0

$ documents [ 'name'] [$ key]을 (를) 사용할 수 없습니까? – dikirill

0

, 당신은 여러 개의 파일이있는 경우 jQuery를 업 로더

$('#fileupload') 
    .bind('fileuploaddone', function (e, data) { 
      console.log(data['result']['files'][0]['name']); 
      console.log(data['result']['files'][0]['url']); 
     }); 

에서 제공하는 fileuploaddone 콜백을 사용하여 JQuery와에 쉽게 처리 할 수 ​​있습니다 : 예를 들어 배열 data['result']['files']을 반복해야합니다.