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? Is there another way to automatically upload a file within an extension? Is there documentation on this?
Thanks,
Mary Beebe
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
Thank you Chad, this was very helpful.
If others want to do the same just look at the method is initializeFromUpload() within includes/specials/SpecialUpload.php. Make sure all of those variables get set correctly before running processUpload().
Thanks for your help,
Mary Beebe
-----Original Message----- From: wikitech-l-bounces@lists.wikimedia.org [mailto:wikitech-l-bounces@lists.wikimedia.org] On Behalf Of Chad Sent: Monday, June 29, 2009 1:37 PM To: Wikimedia developers Subject: Re: [Wikitech-l] Automate uploading files
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
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
You can use the image import maintenance script. It's convenient.
On Mon, Jun 29, 2009 at 10:38 AM, Beebe, Mary J BeebeM@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? Is there another way to automatically upload a file within an extension? Is there documentation on this?
Thanks,
Mary Beebe
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org