GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.mediawiki.org — Manual:importImages.php - MediaWiki
importImages.php is a script which uploads images to MediaWiki from the same computer where the wiki is configured. It does a remote upload if configuration parameter $wgForeignFileRepos is configured correctly, or if you are using an extension that correctly configures it, such as the AWS (S3) extension. If you plan on importing the file descriptions on the image pages too, then you should do that before you run importImages.php. Otherwise, those file descriptions will be buried underneath the import in the page history. If you make this mistake, then you can fix it with a bot script such as FixFileDescriptionPagesBot.php .
ExamplesUpload with default comment "Importing file" and default user "Maintenance script": php maintenance/run.php importImages /path/to/images/directory Upload with custom comment "Importing files from local file repository" and default user "Maintenance script": php maintenance/run.php importImages /path/to/images/directory --comment="Importing files from local file repository" Upload with custom comment "Importing files from local file repository" and custom user "Upload admin" (which must already exist, or an error will occur): php maintenance/run.php importImages /path/to/images/directory --comment="Importing files from local file repository" --user="Upload admin"
php maintenance/run.php importImages /path/to/images/directory --comment="Importing files from local file repository" --user="Upload admin" --search-recursively
importImages.php will not overwrite images if an image with the same name already exists on the wiki. Therefore upload with custom comment "Importing files from local file repository", custom user "Upload admin" and overwrite existing images: php maintenance/run.php importImages /path/to/images/directory --comment="Importing files from local file repository" --user="Upload admin" --overwrite The same as above but only overwriting the given image types, e.g. pdf: php maintenance/run.php importImages /path/to/images/directory --comment="Importing files from local file repository" --user="Upload admin" --overwrite --extensions=pdf An example of what a successful import of one image (Foo.jpg) looks like:
It is probably a good idea to run this script as the
apache user (Commonly either apache or www-data). Otherwise the uploaded files will be owned by the person who ran the script, which may prevent MediaWiki from being able to move, delete, or otherwise manipulate the files later on.Arguments
$ php maintenance/run.php importImages Import Images Imports images and other media files into the wiki Usage: php maintenance/run.php importImages [OPTION]... <dir> <dir> : Path to the directory containing images to be imported In MediaWiki version MediaWiki 1.39 and earlier, you must invoke maintenance scripts using
php maintenance/scriptName.php instead of php maintenance/run.php scriptName.
--comment-ext defines a file extension like .meta that contains the file comment, i.e. the content of the wiki-metadata-page associated with each imported file. This supports per-file metadata, whereas the --comment option supports only per-import metadata. The value of --comment-ext works with or without a leading dot (.meta as well as meta), the value may be quoted or not. The associated file is searched both as appended and substituted extension. Thus, importing x.jpg and setting --comment-ext meta or --comment-ext=meta either of x.meta or x.jpg.meta will be used to set the initial metadata page (i.e. the page shown for File:x.jpg).The "canonical database form" required by
--from is obtained from the file name by capitalizing the first letter, replacing all spaces with underscores, and then replacing multiple consecutive underscores with one underscore. For example, to start with the file someFile with __weird_ spaces.png, the correct argument would be --from=SomeFile_with_weird_spaces.pngTroubleshootingCould not open lock fileTry Does not find the picture to uploadExample where the script does not find any picture to upload: vi-notebook:/var/lib/mediawiki1.7# php maintenance/run.php importImages /store/wiki/absurd_pic jpg Import Images Warning: Invalid argument supplied for foreach() in /usr/share/mediawiki1.7/maintenance/run.php importImages on line 34 Incorrect folder path t@f66677:~/public_html/dead.com/public/w/maintenance$ php run.php importImages /m gif bmp PNG JPG GIF BMP Import Images No suitable files could be found for import. Usually this is because the path to the folder is incorrect. Upload failed error
The following error can be caused by two issues:
Problem 1 - Directory permissions needs to be changed
Problem 2 - user does not have the privileges to upload the pictures See also
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||