Manual talk:Configuring file uploads

Upload link not shown in Toolbox
The Upload option is not displayed in my toolbox. My LocalSettings.php upload configuration is this: $wgEnableUploads = true; $wgGroupPermissions['autoconfirmed']['upload'] = true; $wgGroupPermissions['autoconfirmed']['reupload'] = true; $wgGroupPermissions['user']['upload'] = true; $wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'psd', 'swf', 'fla', 'mp3', 'mp4', 'm4v', 'mov', 'avi'); The Server Settings seem to be right, but if not that wouldn't prevent MediaWiki to show the Link wouldn't it?

09:27, 17 December 2010 (UTC)

Solved the problem there was another "$wgEnableUploads = false" in the File.

91.37.53.90 09:54, 17 December 2010 (UTC)

Cannot upload file name for the gbk code
I want to provide a convenient way to upload,But in the program utf-8 mediawiki cannot upload file name for the gbk code.Please try for this file name. 新建文本文档.pdf
 * MediaWiki version: 1.16.0
 * OS:Windows 7
 * IE:Intelnet Explorer 8/Opera 10
 * Is the server running Windows? Max Semenik 09:42, 8 December 2010 (UTC)

Can upload file name for gbk code, but cannot point it(the url is error)
The server is running in Windows. I can upload the file with chinese name to server as follows, 标志.jpg but the file is renamed to corrupted characters in the server directory as follows, 鏍囧織.jpg And then, the url in the file page is error as follows, The requested URL /ismwiki/images/1/15/æ ‡å¿—.jpg was not found on this server.
 * MediaWiki version: 1.16.1
 * Mysql:5.5.8
 * PHP:5.3.3
 * OS:Windows Server 2003

Cannot upload PDFs
I cannot upload PDFs to my wiki. I am logged in as a sysop. I can upload images just fine. The research I have done leads be to believe these changes in LocalSettings should do the trick, but they don't... The public directory is now 777. I don't an error message. $wgEnableUploads      = true; $wgAllowExternalImages = true; $wgAllowCopyUploads 	= true; $wgAllowImageMoving		= true; $wgFileExtensions[] = 'pdf'; $wgVerifyMimeType = false; $wgStrictFileExtensions = false; $wgCheckFileExtensions = false; ini_set( 'memory_limit', '64M' ); /** This is a flag to determine whether or not to check file extensions on upload. */ $wgUploadSizeWarning = true;
 * MediaWiki version: 1.16.0beta2
 * PHP version: 5.2.6-1+lenny4 (apache2handler)
 * MySQL version: 5.0.51a-24+lenny2+spu1
 * URL: http://www.theyesmenfixtheworld.com/guide (un: guest pw: todayonly!)
 * 1) $wgUseImageMagick = true;
 * 2) $wgImageMagickConvertCommand = "/usr/bin/convert";
 * 3) allow more file types:
 * 1) trying to get pdfs to work
 * 1) $wgMimeDetectorCommand = "file -bi";

Any advice? --Two7s clash 16:08, 23 April 2010 (UTC)
 * $wgEnableUploads as the very last line. Setting it to true before setting $wgAllowExternalImages and $wgVerifyMimeType can cause errors.  See '".[FILE EXTENSION]" is not a recommended image file format.' below.  --Brian F. 19:46, 10 August 2010 (UTC)

False folder permission
After uploading images I'm not able to see them because the subfolders don't have the permission 755. Can I change that automatically or do I have to change them after every upload? It would also be ok if all images would be stored in the images/ folder instead in the images/firstletter/firstletternumber. I hope someone can help me.

MediaWiki's $wgEnableUploads vs. PHP's file_uploads
How come when editing MediaWiki's $wgEnableUploads between true and false becomes noticeable immediately (unable to upload vs. upload enabled) but editing PHP $file_uploads (if already 'on') is not impacting/denying my upload experience at all?


 * You have to restart Apache for your PHP config changes to take effect

End User

 * Who is the "end user"; someone accessing the wiki using a web browser, or a local user on the machine running the wiki?

In this case, "end user" refers to the user accessing the wiki using a web browser.

File Types

 * Are file uploads only for images, or for any type of file?

You can configure MediaWiki to accept additional file types using the $wgFileExtensions configuration setting.

Chmod

 * Shouldn't the chmod for the upload directory be 744? That gives rwxr--r--.  755 gives r-x, which I thought was what we were trying to avoid...


 * Execute privilege on directories is required to access files inside them. (Yes, this is confusing. Blame AT&T.) --Brion VIBBER 00:47, 19 February 2006 (UTC)

There are pages on this site that say 744,755,777. Could someone explain wich to use when?

The important thing is that the webserver has write access. Thus if the upload directory is owned by the webserver user ( e.g. www-data ) 755 would suffice. If the webserver is not owner, but is in the group owning the directory, 775 would be better. 777 is the extreme case where all users on the system have full access. In most cases this would not be advisable.

Making Uploads Lowercase
Does anyone have any idea how to allow files to be uploaded and named with lowercase letter, for some reason all uploaded file default to a capital letter for the first letter of the file name? 24.3.123.174 21:13, 3 May 2006 (UTC)
 * wuh. just under a year response time. Anywho: A technical limitation of Mediawiki is that all pagenames have to start with an uppercase letter. this is most likely the cause for all files beeing renamed.195.230.62.186 12:24, 2 May 2007 (UTC)

The file is corrupt or has an incorrect extension. Please check the file and upload again.
I did as mentioned.

It's a little frustrating, but it seems like mediawiki does not bother that I changed settings in localsettings.php.

I added zip as an extension, than I turned off the extension check, then I turned of mime check etc.

Still I can only upload images and no zip files.

what to do?

How I fixed it
I had to set $wgVerifyMimeType=false; in my LocalSettings.php which means my mime types are probably screwed up. Its an symptomatic fix to a bigger problem, i suspect.


 * Perhaps have a look at Manual:Mime type detection -- Duesentrieb ⇌ 11:10, 6 March 2007 (UTC)

".[FILE EXTENSION]" is not a recommended image file format.
I have set file extensions to allow wmv and avi, set $wgStrictFileExtensions=false; and $wgVerifyMimeType=false in LocalSettings.php, but get the message " ".avi" is not a recommended image file format. " (same for .wmv) when I try to upload avi (and wmv) files. Files sizes are under the cap in php.ini. I have not problems uploading static image files (eg .jpg, .png).


 * With $wgStrictFileExtensions=false, you will still get that warning, but should be able to override it ("upload anyway" or some such). $wgVerifyMimeType=false has nothing to do with this, it just tells MediaWiki not to check if the file actually is an avi file (failing that test would result in a different error message though). -- Duesentrieb ⇌ 11:45, 21 April 2007 (UTC)


 * Thanks for the speedy response. Unfortunately no override option appeared on the screen.  I just got "Upload warning" header above the "not a recommended image file format" message.  This also happened when I check "Ignore any warnings" on the upload screen.  However, I then rearranged the order of in LocalSetting.php so that $wgStrictFileExtensions=false appeared before $wgEnableUploads=true and $wgFileExtensions = ....  I can now upload video files without any difficulties.


 * Turning of $wgStrictFileExtensions seems a little dangerous. I fixed a similar problem I was having with xls files by adding the following line to mime.types:


 * application/msword xls</tt>


 * Depending upon the mime detection engine on your server, certain types are misidentified. The true solution is to fix the engine, but this is a pretty safe alternative. - dan

MUst be server pixies then. -- Duesentrieb ⇌ 13:21, 21 April 2007 (UTC)

This file is bigger than the server is configured to allow
How do you change the maximum allowed size of a file for uploading?

This is what I have in my php.ini:

upload_max_filesize = 250M
 * Maximum allowed size for uploaded files.

(default was 2 MB)

You may also have to change post_max_size in the same file. Apache itself might also have a limit set. And keep in mind that you have to restart apache for any changes to the php configuration to take effect.

Linking to .mov files (Quick Time) won't work
After: allowing uploading of .mov files to my wiki, successfully uploading a certain .mov file and watching it from the page I've been directed to, I found my wiki won't link to it. If I type, for instance, [[Media:Example.mov]] (assuming my .mov file's named Example), I'd get a red link, leading to "Upload file" page. What am I doing wrong? --87.69.58.71 17:53, 4 November 2006 (UTC)

Upload Priviledges
Is there a way to set it so that only SysOp can upload files?
 * Try meta:Uploading_files --Flominator 07:26, 29 January 2007 (UTC)

anonymous uploads
Is there a way to allow users to upload files without logging in?

That'd be a great help for corporate environments where only a limited number of people can access the wiki (server) anyway... --- $wgOut->errorPage( 'uploadnologin', 'uploadnologintext' ); return;
 * Edit SpecialUpload.php file in the includes folder
 * Comment out the following two lines:

Now users will not have to login to reach the upload form.

Simpler method, modify LocalSettings.php: $wgEnableUploads      = true; $wgGroupPermissions['*']['upload'] = true;

In which file is variable $wgFileExtensions?
Im trying to change my extensions list, but it is not in LocalSettings? Where is it?
 * The default is set in includes/DefaultSettings.php. But you shouldn't change it here. Just copy the line into your LocalSettings.php and alter it the way you like here. The intention for this procedure is just that the DefaultSettings is responsible for everything that is NOT explicity set by yourself. Also if you like to make an update someday you won't destroy your current settings, cause the LocalSettings.php won't be touched through an update.

Check directory security
In the manual page, it says under "Check directory security" that "The upload directory needs to be configured so that it is not possible for an end user to upload and execute other scripts, which could then exploit access to your web directory and damage your wiki or web site."

Unfortunately, the PHP function that makes subdirectories is:

and many places that call this use the fault mode 0777 which is world-writable. For example, everywhere in Image.php it uses one argument calling this method, such as:

The consequence of this is that every directory recursively under images is world-writable. The files themselves seem to be fine (mode 644), however, any user who can login to the system on which the MediaWiki instance is running can copy or destroy files at will.

Can we get wfMkdirParents (and everywhere that 0777 is passed to that method) to use a mode of 0755 instead? --Caswick 21:09, 15 March 2007 (UTC)

How to link "other" file types on pages?
Case 1 - When i want to upload images, i follow the following steps Simple.
 * go to page edit
 * write a suitable name
 * make it into an image link by clicking the 6th button from the left on the edit menu
 * save page
 * view page, the link is shown in red.
 * click it and upload the image

But with file types other than images,it give an error as to "not a jpeg format", there is no such option. I have to link the thing by copy/pasting the exact names everytime. There must some other way around! Please help me on this !! --Ankit.madan 07:12, 21 August 2007 (UTC)

Error when uploading from URL
Fatal error: Call to undefined function curl_init in /path/to/wiki/includes/SpecialUpload.php on line 165

Any idea what could cause this? I've googled it, but it seems only the chinese have experiences this problem. Using MW 1.11 - followed the directions on the configuration page. Regular uploads work fine.

I solved this by typing on Ubuntu: 'sudo apt-get install php5-curl' followed by 'sudo /etc/init.d/apache2 restart'

Folder permissions & SUPHP
If you are using suphp you might want to check the suphp configuration file ( /etc/suphp.conf )

and ensure the Umask value is set to something sane (so when the folders get created they get the proper permissions)

umask=0022
 * Umask to set, specify in octal notation

You can also set the umask locally at the LocalSettings.php:

umask(0022);

Multiple Uploads
Is it possible to upload multiple files at one time (like for a photo gallery) rather than uploading each file individually? Or if I FTP them to my server without using MediaWiki's upload page, can I still use the &lt;gallery&gt; tags to display them somehow?


 * There's Extension:MultiUpload, havn't tried it though. If you upload files directly to the server using FTP or SCP or whatever, you have to import them into MediaWiki to make them work wiki-style: That is done using maintenance/importImages.php but it requires shell access. I believe some of the bots that exist for mediawiki also support file upload, but I havn't looked into that. There's also the commonist upload tool, which was designed for wikimedia commons, but can be adopted to other sites as well.
 * HTH -- Duesentrieb ⇌ 06:56, 11 April 2008 (UTC)


 * Thanks so much for the info! I do have shell access, and I think FTP and import would probably the fastest for lots of images. I may use MultiUpload as well - it would be nice if I had just a few files.


 * Just saw that I do not want drag'n'drop mutple upload via interface. Too much abuse. Will also try MultiUpload. Thanks --Subfader 04:55, 7 December 2008 (UTC)
 * The absolute best extension for this is Extension:SpecialUploadLocal which currently works for all version but 1.16. Adamtheclown 08:35, 15 November 2010 (UTC)

Image File Names
I'm webmaster of http://venciclopedia.com, a Spanish language wiki. We recently moved from one hosting server to another and it took us weeks to finish the migration because of problems with the names of some images. The main problem was that our former hosting (yahoo) didn't allow the creation of files or folders with certain characters, but wiki did it anyway and we didn't care until we moved away. Our former wiki could read the folders and images in them, but we could not see them or ftp them out of yahoo because of invalid characters in the names.

This was most likely solved by our move to a new hosting and upgrade to the latest wiki, but after so many problems I simply don't want to risk it. My question: There's way to forbid users from uploading files with names containing symbols (as in #, @, etc) and accented words (as in "ó")?

Right now we are running with a modification I did to Specialupload.php in line 426, where I changed this: $filtered = preg_replace ( "/[^".Title::legalChars."]|:/", '-', $filtered ); To this: $filtered = preg_replace ( "/[^a-z0-9\\040\\.]|:/i", 'x', $filtered );

With this change users cannot upload files with symbols or accented words, but they still can upload the "ugly" and nondescriptive file names created by my patch. Meaning, words with a bunch of X's where the symbols or accented words used to be.


 * So, is there a way to just reload the page and say, Please change your filename, such and such characters are invalid?
 * Is there a way to transform accented words like "ó" into plain "o"s?

In Especial:Allmessages I found a message titled illegalfilename that warns against using invalid characters, so I guess there's some sort of option without having to change Specialupload.php directly.

Thanks in advance, here's my upload page in case you need to test it. http://venciclopedia.com/index.php?title=Especial:Upload

--Mark 09:55, 25 April 2008 (UTC)

Upload files to FTP server
Is it possible to upload files to FTP server?

Yes, then use /maintenance/importImages.php Read above section.

Odd filenames?
Hey, I recently installed the newest Mediawiki and any files (I only tried images though) I upload always come up as Image:[USERNAME]--[IMAGENAME].[extension]. Is there any way to make it just go to the file name? Thanks. --Ratmaster 21:37, 21 November 2008 (UTC)


 * I'm getting this too on a small wiki I'm an administrator on. There doesn't seem to be any obvious setting in includes/specials/SpecialUpload.php, does anyone have any clues they could offer me on where to look? Bryan Derksen 06:27, 15 June 2009 (UTC)


 * After digging a bit further on this site I found the answer here: Project:Support_desk/Archives/Images/002. Apparently the "KeepYourHandsToYourself" extension is responsible. Commenting out the line

'extensions/KeepYourHandsToYourself.php' -- $wgHooks['UploadForm:BeforeProcessing'][] = 'prependUsernameToFilename';


 * seems to be one way to fix it. Bryan Derksen 06:35, 15 June 2009 (UTC)

File size and postgres
Hi,

I'm using mediawiki1.7 with postgres. When uploading a file, the pg_query can't write in img_size in the image table and I get an error message -

ERROR: value "202205" is out of range for type smallint

and some other details...

...out of range for type smallint in /usr/share/mediawiki1.7/includes/DatabasePostgres.php

I have modified $wgMaxUploadSize and $wgFileExtensions in LocalSettings.php

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'ppt', 'pdf', 'doc', 'psd', 'mp3','xls', 'zip','swf', 'doc', 'odt', 'odc', 'odp', 'odg', 'mpp'); $wgUploadSizeWarning = 1000 * 1024; $wgMaxUploadSize = 1024 * 1024 * 100;

This did not help. I think, the problem is in the definition of the image table. Is there a way to enable upload of larger files, up to 2M?

Thank you in advance,

Twisp

Changing the text on the File Upload Page
How does one change the text on this page?

I need to add some extra copyright warning text.

--Stuart Halliday 14:44, 12 January 2009 (UTC)

Ah. Discovered how to do this: Go to the 'MediaWiki:Uploadtext' page of your Wiki and edit it. --Stuart Halliday 15:15, 12 January 2009 (UTC)

Missing File = Errors
Right up in Prerequisites, it mentions that a file called php.ini needs to be changed to allow uploads. Problem is, I searched though on my FTP thing, and I don't seem to HAVE a file called php.ini. I did change the bit for LocalSettings.php, and that much allows me to upload images... but to try looking at the page for it, or a page that it's supposed to appear on at all, all that comes up is a 500 Internal Server Error that includes, "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

So... I have no idea what to do.


 * php.ini is a system configuration file; you probably don't have access to it. Your host may or may not be willing to change settings in php.ini for you, and may or may not have a way for you to use your own custom php.ini file.


 * In any event, you are able to upload files, but the resulting image pages give internal server errors? Enable error reporting and post what you find. —Emufarmers(T 15:24, 7 February 2009 (UTC)

Upload on a different FTP server
Is it possible to change the directory of images to a differnt FTP Server? At the moment all images are placed on server1 with all the other folders. Is it possible to extract just the image folder to a different FTP server? The rest of the wiki folders will stay on server1. How do I address the server2 with the uploaddirectory and the uploadpath?
 * I would also like this feature. My hosting providers offers a separate service for just file hosting without scripting.  It's much cheaper, get lots of space, and great transfer allocations.  Then, it would be images.mydomain.tld.  But, it only has FTP access for uploads, and HTTP access for downloads.  192.55.55.39 21:53, 19 May 2010 (UTC)

Upload from URL
On trying to upload a pic directly from an URL I get an error message

'''Warning: file_exists:open_basedir restriction in effect. File(/temp/xcvsderd)is not within the allowed path(s): (/var/www/web/html:/var/www/web/phptmp:/var/www/web/files:/var/www/web/atd: ...............in /var/www/web/wiki/includes/specials/SpecialUpload.php on line 150'''

I'm runnig MediaWiki 1.14.0 mysql    5.0.51 php      5.2.9

What am I doing wrong ? How to "config" this feature ? Thanks

Red ant 18:33, 19 April 2009 (UTC)

File uploads in 1.15.1
Hey, I'm upgrading from 1.11 to 1.15.1. I have a lot of customized extensions, so I set up 1.15.1 in a separate area of my server to test it out first. However, in 1.15.1 I can't enable file uploads. It says "Uploads disabled. File uploads are disabled in PHP. Please check the file_uploads setting." But my php settings are unchanged, file_uploads is on and it is working fine in the already installed 1.11 wiki (same server but different folder, same database but different table prefixes). Do anyone know what could cause this? I have set $wgEnableUploads=true, and I have set the upload folder to be writable by the server (even set it to 777 just to check). I'd be grateful for any help! --Anderssl 22:41, 10 September 2009 (UTC)

Logon
I've added this topic to the main article. I spent a few hours trying to get my uploads working and it wasn't until I saw the Upload File option under Special Pages that it finally told me I had to register and logon. This would be expected for Wikipedia but for own wikis starting up people (like me) won't necessary register and logon to set it up. 118.209.221.29 21:04, 11 October 2009 (UTC)

Fails to rename if tmp and image dirs reside in different volumes (Windows)
I had the following problem with mediawiki installed on Windows with wamp server and it took me pretty long to solve it:

If the temp directory is in a different volume that the image directory, then the error "could not rename x to y" error arises. That's because PHP (at least version 5.3) does not like renaming files among volumes. In my case I had wamp installed on C: (so the temp directory was the default one c:/wamp/tmp) and wamps webroot directory installed on D: (so the image directory was something like D:/wamp/www/mediawiki/images).

I know this is no strictly a mediawiki issue, but it would have saved me lots of time if a note about this was included in the article.

--Mmutilva 13:23, 25 November 2009 (UTC)

finding php.ini
neither of the commands on the main page worked for me in putty.exe ro find php.ini, so searching the internet i found this:

For an example of where the php.ini file is: see Where is php.ini located?. Igottheconch 08:43, 16 January 2011 (UTC)