On Mon, Jun 29, 2009 at 12:38 PM, Beebe, Mary JBeebeM@battelle.org wrote:
I am trying to automate uploading images (or files). We are currently using mediaWiki version 1.13.2.
I am using the following code: $data=array( 'wpIgnoreWarning'=>'1', 'wpDestFile'=>="$bulkImageDirectory/$fname", 'wpReUpload'=>'1', 'wpUpload'=>'1', 'wpUploadFile'=>$fname, ); $webrequest=new FauxRequest( $data, true ); $uploader=new UploadForm( $webrequest ); $uploader->mUploadSize=$zipfile['size']; $uploader->mUploadTempName="$bulkImageDirectory/$fname"; $uploader->mOname=$fname; $uploader->mSessionKey='1'; $uploader->processUpload();
$fname is a relative file name, while ="$bulkImageDirectory/$fname" is the absolute file name. The file is located in wiki/images/tmp/bulkImages/.
I receive the error: "The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file." And the upload form displays on the screen with wpDestFile filled in.
Three questions: Do you know what the problem is?
Yes, you need to set mFileSize (not mUploadSize, there's no such thing) and mSrcName (not sure what to, offhand...). I'd suggest taking a look at internalProcessUpload() and its various return states for more info.
Is there another way to automatically upload a file within an extension?
What you're doing is the only way (right now) to really do this. It sucks, yes. Hopefully the new-upload branch will make this sort of thing easier and less prone to error.
Is there documentation on this?
Not really :\
-Chad