<form enctype="multipart/form-data" action="" method="POST">
Выберите файл: <input name="userfile" type="file" />
<input type="submit" value="Отправить файл" name="send" />
</form>
<?php
if ($_POST['send']){
$uploaddir = 'test/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Файл корректен и был успешно загружен.\n";
}
echo "<script> ";
echo "var br1 = document.createElement(\"br\");";
echo "document.body.appendChild(br1);";
echo "var mycolor = document.createElement(\"INPUT\");";
echo "mycolor.setAttribute(\"type\", \"color\");";
echo "document.body.appendChild(mycolor);";
echo "var br2 = document.createElement(\"br\");";
echo "document.body.appendChild(br2);";
echo "var newCanvas=document.createElement(\"canvas\");";
echo "newCanvas.id=\"myCanvas\";";
echo "document.body.appendChild(newCanvas);";
echo "var canvas = document.getElementById('myCanvas');";
echo "var context = canvas.getContext('2d');";
echo "canvas.addEventListener('click', function(event) {";
echo "var xVal = event.pageX - canvas.offsetLeft;";
echo "var yVal = event.pageY - canvas.offsetTop;";
echo "context.fillStyle = mycolor.value; ";
echo "context.fillRect(xVal,yVal,10,10 );";
echo "});";
echo "var imgObj = new Image();";
echo "imgObj.src = \"$uploadfile\";";
echo "imgObj.onload = function(){";
echo "canvas.width = imgObj.width;";
echo "canvas.height = imgObj.height;";
echo "context.drawImage(imgObj,0,0);";
echo "}";
echo "</script>";
}
?>
|