2011-02-21 1 views
2

WP functions.php에 업로드 기능을 쓰려고합니다. 그것은 위대한 일을 wp - 관리자에게 파일을 업로드, 나는 그것이 get_bloginfo로 액세스 할 수있는 테마 디렉토리에 들어가고 싶지만 ...하지만 절대 주소입니다.WordPress에 PHP 업로드 문제 -> 테마 디렉토리에 업로드하고 싶지만 기능이 관리 디렉토리에 로컬입니다.

동일한 사이트에 있지만 동일한 디렉토리에있는 디렉토리에 파일을 업로드 할 수있는 방법이 있습니까?

파일 구조는 기능은 WP-관리자에서 실행이

wp-admin 
wp-content 
    themes 
    Mytheme 

처럼,하지만 난 내 주제에 가고 싶어.

$target_path = get_bloginfo('template_url');//NOT WORKING ABSOLUTE PATH 

$target_path = $target_path . basename($_FILES['uploadedfile']['name']); 
    echo(">> " . $target_path . " <<"); 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { 
    echo "The file ". basename($_FILES['uploadedfile']['name']). 
    " has been uploaded"; 

} else{ 
    echo "There was an error uploading the file, please try again!"; 
} 

답변

1

stylesheet_directory 매개 변수와 함께 get_bloginfo()를 사용하십시오.

참조 : http://codex.wordpress.org/Function_Reference/get_bloginfo#Template_Directory 참조.

시도는 다음과 같이 코드를 수정합니다 :

$target_path = get_bloginfo('stylesheet_directory'); 
+0

오, 즉 그것을 얻을 알고있는 좋은 사람. 상대 경로를 사용하는 솔루션을 찾았지만 더 깨끗해야합니다. 나는 그것을 시도 할 것이다 - 감사합니다! – GregB

관련 문제