With this method you can attach files not bigger than 50MB. Other file size limits also apply:
site storage: can't upload file bigger than current unused file storage for site maximum file size depending on free/Pro Wikidot plan

Attaches file to page
argument keys:

  • site: site of page to attach file to
  • page: page to attach file to
  • file: name of file to attach
  • comment (optional): file description
  • save_mode (optional): allowed mode of operation
    • create: only allow creating new objects (exception thrown if object with this name already exists)
    • update: only allow updating objects (exception thrown if no object with this name exists)
    • create_or_update (default): allow both creating and updating object
  • content: base64-encoded file content
  • notify_watchers (optional):
    • true: notify watchers about the edit (as if it was done with the web interface)
    • false (default): don't notify watchers
  • revision_comment (optional): revision comment (displayed in history)

returns: the newly uploaded file information as dictionary the same to what files.get_meta return for each file

This files.save_one demo uses the sample code below. Create a separate file in your hosted site. Change the path to the and files. Change the $fcriteria variables in fileinput_3.php to your wikidot target information and you PHP host file upload location. Change "uploaded/" in fileinput_2.php to your PHP host file location. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site. File content sent is a base64 encoded string.

Full PHP implementation of this API method needs 3 pages on your PHP host or files to already exist on your PHP host.
fileinput_1.php is the PHP form page to select a file from you local machine.
fileinput_2.php is the page that receives the form submittal from fileinput_1.php and uploads the file to the PHP host.
fileinput_3.php is the page that takes the confirmation from fileinput_2.php and saves the file to the wikidot page. fileinput_1 and _2 can be optional if the files already exist on the PHP host.

Click here for an interactive javascript based sample that handles multiple file.

Sample Code


<title>Upload files to Wikidot Demo</title>
<h1>Input File Form</h1>
This page lets you select a file from your local machine.  
The demo does not upload the file.  It uses an already uploaded 
file to complete the process.  The form submit will open another 
page on your PHP hosted site.
<form action="fileinput_2.php" method="post"
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="Submit" />


This is the popup window that takes the form submital and uploads the file to your PHP host.
if ($_FILES['file']['error'] > 0) {echo "Error: " . $_FILES['file']['error'] . "<br />"; }
else  {echo "File from form</br>";
  echo "Upload: " . $_FILES['file']['name'] . "<br />";
  echo "Type: " . $_FILES['file']['type'] . "<br />";
  echo "Size: " . ($_FILES['file']['size'] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES['file']['tmp_name']."</br>";}
$ar = array();
$ar = $_FILES;
//this example only allows image files to be uploaded
$allowedExts = array("jpg", "jpeg", "gif", "png", "bmp");
$extension = end(explode(".", $_FILES['file']['name']));
//check file to see if it is allowed to be uploaded
if ((($_FILES['file']['type'] == "image/gif")
    || ($_FILES['file']['type'] == "image/jpeg")
    || ($_FILES['file']['type'] == "image/pjpeg"))
    && ($_FILES['file']['size'] < 100000)
    && in_array($extension, $allowedExts))  {
    if ($_FILES['file']['error'] > 0){echo "Return Code: " . $_FILES['file']['error'] . "<br />"; }
    else {$tfh = tmpfile();
        $tfh = $_FILES['file']['name'];
        echo "Upload=>: " . $_FILES['file']['name'] . "<br />";
        echo "Type: " . $_FILES['file']['type'] . "<br />";
        echo "Size: " . ($_FILES['file']['size'] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES['file']['tmp_name'] . "<br />";
        //change "uploaded/" to your PHP host file location
        if (file_exists("uploaded/" . $_FILES['file']['name'])){ //file exists, throw error message
            echo $_FILES['file']['name'] . " already exists. ";}
        else{//save uploaded file to PHP host location
                "uploaded/" . $_FILES['file']['name']);
            echo "Stored in: " . "uploaded/" . $_FILES['file']['name'];}}}
else {echo "Invalid file";}
Once file has been uploaded you can now call the files.save_one API method.
This extra step allows time for the upload process to complete.
<form action="fileinput_3.php" method="post">
When the file has loaded, click to continue.
<input type="submit" name="submit" value="Continue" />
<a href="fileinput_1.php">Click here to cancel upload to wikidot page</a>


<title>Upload files to Wikidot Demo</title>
<h1>Save file to wikidot page</h1>
//set globals before includes
    $newdebuglevel = 0;    
//add includes
//change path to your server location
//set startup parameters for xmlrpc
//change path to your server location
    $GLOBALS ['xmlrpc_null_extension' ] = true;
    $ServerPath = "xml-rpc-api.php";
    $ServerHostName = "";
    $ServerPort = "";
//create a client for your site
    $Client = new xmlrpc_client($ServerPath,$ServerHostName,$ServerPort);
    $Client->setCredentials("USERNAME","API KEY");
    $Client->return_type = "phpvals"; //forces return of page.get_one as php values
    $SiteName = "SITENAME";
////////////test code
////////////code doesn't include error checking
    $fileobj = new FilesWikidotMeta($SiteName, $Client);
    $returnarray = array();
    echo "<h3>files.save_one example</h3></br><hr>";
    $fcriteria = array();
//loop this section if you have more files on the PHP host
//on each loop, $fcriteria['file'] and $filename must change, other changes are optional
    $fcriteria['file'] = "FILESAVEASNAME.JPG";
    $fcriteria['page'] = "CATEGORY:PAGENAME";
    $fcriteria['save_mode'] = "create_or_update"; //create, update, create_or_update
    $fcriteria['notify_watchers'] = "false";
    $content = file_get_contents($filename);
    $contbase64 = base64_encode($content);
    $fcriteria['content'] = $contbase64;
//end multiple file loop
    $fileobj->php_files_save_one($fcriteria, $returnarray);
    foreach ($returnarray as $key=>$file){
        if($key != "content") echo $key.": ".$file."</br>";}
<a href="fileinput_1.php">Click here to return</a>

Download Code File

Live demo

Uses above code in an Iframe from a PHP host.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License