나는 사용자에게 Wordpress 페이지에서 이미지를 업로드 할 가능성을 제공하고 업로드하기 전에 이미지 크기를 조정하는 앞 페이지 Wordpress 업 로더를 구현하려고합니다. 애자일 업 로더를 찾았습니다. 업 로더는 양식에 있습니다.Agile Uploader Wordpress 구현
문제는 데이터를 보내기 위해 양식의 제출 버튼을 클릭하면 모든 필드가 게시물에 저장되지만 이미지는 저장되지 않습니다. 내가 잘못 뭐하는 거지 (같은 파일`의)
/* upload photos */
if ($post_error == false) {
/* required files */
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$files = $_FILES['attachment'];
if ($files) {
foreach ($files['name'] as $key => $value) {
if ($files['name'][$key]) {
$file = array(
'name' => $files['name'][$key],
'type' => $files['type'][$key],
'tmp_name' => $files['tmp_name'][$key],
'error' => $files['error'][$key],
'size' => $files['size'][$key]
);
}
$_FILES = array("attachment" => $file);
//$_FILES = array_reverse($_FILES);
foreach ($_FILES as $file => $array) {
$attach_id = media_handle_upload($file, $ad_id, array(), array('test_form' => false));
if ($attach_id < 0) { $post_error = true;
}
}
}
}
을 업로드
<form id="submitForm" action="<?php echo get_permalink(); ?>" method="post" enctype="multipart/form-data" onsubmit="return ray.ajax()">
<!-- upload photos -->
<div style="float:left;width:410px; height:246px;">
<div id="multiple"></div>
</div>
<script type="text/javascript">
jQuery('#multiple').agileUploader({
formId: 'submitForm',
flashVars: {
file_post_var: 'attachment',
firebug: false,
form_action: '',
file_limit: 15,
max_post_size: (1000 * 1024)
}
});
</script>
</div> <!-- end - upload photos -->
</form>
및 워드 프레스에 대한 코드 : 여기
내 업로드 페이지에 대한 코드?
문제는 전체 양식을 저장하는 것입니까? – janw
예. 문제가 있습니까? –
오류 메시지가 있습니까?, 귀하의 방화 친구 콘솔을 확인하고 빠른 답변 –