Hello
I would like to modify the script below, so instead of accessing the file words.dat (a .dat file with a list of words that can be moved around on a page) to an image file of my choosing (the current file I would like to move around is called Sunset.gif).

I am totally stuck
Thanks in advance
Slappy

<?php

$ma = new magneticAjax();

class magneticAjax
{
public $numWords;
public $words;

public function __construct()
{
$this->processFile();
}

public function processFile()
{
$filename = "words.dat";
$fp = fopen($filename, 'r');
flock($fp, LOCK_SH);
$contents = fread($fp, filesize($filename));
flock($fp, LOCK_UN);
fclose($fp);
$this->words = explode("\n", $contents);

$this->numWords = count($this->words);
for ($i=0; $i<$this->numWords; $i++) {
$this->words[$i] = trim($this->words[$i]);
$this->words[$i] = explode("|", $this->words[$i]);
}


if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
if ($_POST['f'] == "save") {
echo $this->save($_POST['id'], $_POST['x'], $_POST['y'], $_POST['z']);
} elseif ($_POST['f'] == "repaint") {
echo $this->repaint();
}
}
}

public function printTiles()
{
$retHTML = "";
for ($i=0; $i<$this->numWords; $i++) {
$tileWidth = 7 * strlen($this->words[$i][1]);
$tileHeight = 13;
$retHTML .= '<div id="w_' . $this->words[$i][0] .
'" class="tile" style="position: absolute; top: ' .
$this->words[$i][2] . 'px; left: ' . $this->words[$i][3] .
'px; width: ' . $tileWidth . 'px; height: ' .
$tileHeight . 'px; z-index: ' . $this->words[$i][4] . '">';

$retHTML .= $this->words[$i][1];
$retHTML .= '</div>';
}
return $retHTML;
}

private function repaint()
{
$retVal = "";
for($i=0; $i<$this->numWords; $i++){
$retVal .= $this->words[$i][2] . ":" . $this->words[$i][3] . ":" . $this->words[$i][4];
if($i < $this->numWords-1){
$retVal .= "|";
}
}
return $retVal;
}

private function save($obj, $x, $y, $z)
{
$index = substr(strrchr($obj, "_"), 1);
$index--;
$this->words[$index][2] = $y;
$this->words[$index][3] = $x;
$this->words[$index][4] = $z;

$str = "";
for($x=0; $x<$this->numWords; $x++){
$str .= $this->words[$x][0] . '|' .
$this->words[$x][1] . '|' .
$this->words[$x][2] . '|' .
$this->words[$x][3] . '|' .
$this->words[$x][4];
if($x<$this->numWords-1){
$str .= "\n";
}
}

if ($fp = fopen("words.dat", "a")) {
if (flock($fp, LOCK_EX)) {
fseek($fp, 0);
ftruncate($fp, 0);
fwrite($fp, $str);
flock($fp, LOCK_UN);
fclose($fp);
}
return;
}
else {
return "Could not open file!";
}
}
}