현재 MediaWiki (1.16) 설치 (로컬 인트라넷에 있고 외부에서 액세스 할 수 없음)에서 다른 곳으로 기사를 복사하려면 Extension:Push을 사용하고 있습니다. 그러나 Push는 원격 MediaWiki가 파일을 다운로드하도록 만 할 수 있습니다.이 경우 불가능합니다 (인트라넷 위키는 외부에서 접근 할 수 없습니다).PHP를 통해 미디어 위키에 파일 업로드
그래서 MediaWiki의 업로드 API에 직접 바인딩 할 방법이 필요합니다. 나의 현재 시도는 다음과 같다 :
$header = 'Content-Type: multipart/form-data; boundary='.$multipart_boundary.'\r\n'.
'Cookie: '.$cookies;
$file_contents = file_get_contents ($imagePage->getDisplayedFile()->getFullUrl());
$content = "--".$multipart_boundary.'\r\n'.
'Content-Disposition: form-data; name="file"; filename="'.basename($imagePage->getDisplayedFile()->getFullUrl()).'"\r\n'.
'Content-Type: application/octet-stream\r\n\r\n'.
$file_contents.'\r\n'.
'--'.$multipart_boundary.'\r\n'.
'Content-Disposition: form-data; name="action"\r\n\r\n'.
'upload\r\n'.
'--'.$multipart_boundary.'\r\n'.
'Content-Disposition: form-data; name="format"\r\n\r\n'.
'json\r\n'.
'--'.$multipart_boundary.'\r\n'.
'Content-Disposition: form-data; name="ignorewarnings"\r\n\r\n'.
'1\r\n'.
'--'.$multipart_boundary.'\r\n'.
'Content-Disposition: form-data; name="token"\r\n\r\n'.
$token.'\r\n';
$context = stream_context_create (array (
'http' => array (
'method' => 'POST',
'header' => $header,
'content' => $content,
),
));
$response = file_get_contents ($target, false, $context);
내가 (어느 지역이나 원격 아파치) 오류 메시지가 표시되지 않지만, 파일이 하나, 표시되지 않습니다. 누구나 잘못된 생각을 갖고 있거나, 해결책을 가지고 있거나 적어도 참여한 미디어 위키 (mediawiki) 기능을 지적 할 수 있습니다. 따라서 디버그 로깅을 넣을 수 있습니까?