Using Semantic Forms for file pages and uploads

When files are uploaded to Mediawiki, a page is created for that file in the File namespace, using the filename of the file as the title of the page. For example, the page for MySillyFace.jpg would be called File:MySillyFace.jpg, assuming the user does not change the filename in Mediawiki's upload dialog to something like File:MySexyFace.jpg.

Semantic Forms normally requires the name of a page to be entered BEFORE it can create it. This is a problem if Semantic Forms is being used to upload files that are supposed to have semantic data associated with them, because the name of the page is not known until AFTER the file is uploaded and given a name, since the page name will be based on the file's name.

The info tag can be used to allow the page name to be extracted by Semantic Forms from the filename of a file AFTER a file is uploaded, instead of using the normal method of specifying the page name before a file is uploaded. This allows Semantic Forms to add properties to the file's page.

Let's say you have files you want to upload that should have semantic property data associated with them that will tell you some basic facts about the file.

You will need to precede your semantic form definition with an info tag that uses the page name= parameter to specify the name of the page to be created. Since you don't know what the page name will be until after someone uses the form to upload a file, the page name will have to be extracted from the filename of the uploaded file. This can be done using a parameter of the form 

You must put "File:" in front of that parameter so that the page is created in the correct namespace. The completed info tag should look like this:

Note that you must already have created a template called "MyFileTemplate" that contains a property for the file name, to use on file pages. Since the file name is already in the title of file page, this may seem like an unnecessary step. But, Semantic Forms can't access the name of a page that it hasn't created yet, so the file name property is a simple workaround that is required (temporarily) to give Semantic Forms something it can use to keep track of what the created page name will be.

You template properties should look something like this:

Your form would then look something like this:

Free text:

Note that if you want to use this form to create file pages with the proper file page name, you should not access it using the form page. Instead access it from this special page:

Special:FormEdit/YourSemanticFormNameHere/

Normally, the page name would be at the end of that, like this:

Special:FormEdit/YourSemanticFormNameHere/NewPageNameToBeCreated

Your users should not have to type in the correct URL to get to your file upload, so it will be helpful if you just put a button or link on your site that can take them there. Here's a button example:

Here's a link example:

Special:FormEdit/YourSemanticFormNameHere/

The button can do creative things like prefill some field of the form, depending on what page the button was on when it was clicked. The following example will fill in YourProperty 1 on the form with the name of the page where the button was clicked: