wordpress의 맞춤 PHP 플러그인에 로고 업로드 기능을 추가해야합니다. 나는이에 파일을 제출하는 경우 그것은 나에게 다음과 같은 오류를 제공Wordpress 업로드 기능을 사용하여 파일을 업로드 할 수 없습니다.
<form action="' . site_url('/edit-company/?cid=' . $_GET['cid']) . '" method="post">
<label><b>Company Name:</b></label> <input type="text" name="editname" value="' . $company->company_name . '">
<label><b>Address:</b></label> <input type="text" name="editaddress" value="' . $company->company_address . '">
<label><b>Telephone:</b></label> <input type="text" name="edittelephone" value="' . $company->company_telephone . '">
<label><b>Fax:</b></label> <input type="text" name="editfax" value="' . $company->company_fax . '">
<label><b>Email:</b></label> <input type="text" name="editemail" value="' . $company->company_email . '">
<label><b>Website:</b></label> <input type="text" name="editwebsite" value="' . $company->company_website . '">
<label><b>Logo:</b></label> <input type="file" name="editfile" id="file">
<input type="submit" value="Submit">
</form>
: 나는 워드 프레스 사본에이 코드를 발견 : 여기
if (! function_exists('wp_handle_upload')) require_once(ABSPATH . 'wp-admin/includes/file.php');
$uploadedfile = $_FILES['editfile'];
$upload_overrides = array('test_form' => false);
$movefile = wp_handle_upload($uploadedfile, $upload_overrides);
if ($movefile) {
echo "File is valid, and was successfully uploaded.\n";
var_dump($movefile);
} else {
echo "Possible file upload attack!\n";
}
양식입니다
File is valid, and was successfully uploaded. array(1) { ["error"]=> string(212) "File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini." }
제출할 파일 크기는 약 50kb입니다. 더 크거나 작은 파일을 업로드하는 것은 효과가있는 것 같지 않습니다.
WordPress admin에서 어떤 크기의 파일을 업로드해도 문제가 없습니다. php.ini 또는 최대 크기를 게시하는 것이이 문제의 원인이라고 생각하지 않습니까?
여기에 대한 정보 나 조언이 있으면 알려 주시기 바랍니다. 나는 꽤 오랫동안 이것에 붙어 있었다. vanilla PHP에서 간단한 업로드 스크립트를 사용해 보았습니다.하지만 작동하지 않는 것 같아서 wp 함수로 끝내려고합니다.
UPDATE : 는 - 777에 업로드 폴더의 사용 권한을 설정하지 시도 - 더 도움
양식의 속성이 추가하십시오 . –
wp uploads 폴더의 권한을 775로 설정하는 것이 안전합니까? –
예 775 권한을 설정하는 것이 안전합니다. –