Skip to content

Commit

Permalink
WIP: almost there!
Browse files Browse the repository at this point in the history
can pass variables to php script
  • Loading branch information
NicolasRannou committed Dec 1, 2011
1 parent a4b5d04 commit 6f8f364
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
69 changes: 69 additions & 0 deletions ajax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function getXMLHttp()
{
var xmlHttp

try
{
//Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
//Internet Explorer
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("Your browser does not support AJAX!")
return false;
}
}
}
return xmlHttp;
}

function RequestImage(filename)
{
var xmlHttp = getXMLHttp();

xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText, filename);
}
}

xmlHttp.open("GET", "ajax.php?var1=value1&var2=value2", true);
xmlHttp.send(null);
}

function HandleResponse(response, filename)
{
//document.getElementById('preview').innerHTML = ag.concat("/>\"");
document.getElementById('filtered').innerHTML = response;
}

function openFile(file) {
//document.getElementById('preview').innerHTML = "<img src=bank/rannou/25696c5.jpg>";
var im = "<img src=";
var ag = im.concat(file.substring(6));
document.getElementById('preview').innerHTML = ag.concat(" height=\"200\" width=\"200\" />");
//RequestImage(file);
}

function preview(file) {
RequestImage();
// get image name
// get filter
// server process
// server sends new image location
}
4 changes: 4 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$cat=&$_GET['var1'];
echo $cat;
?>
Binary file added bank/arrow_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bank/rannou/25696c5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bank/rannou/Sample16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bank/rannou/Sample17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bank/rannou/arrow_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added bank/rannou/tot.txt
Empty file.
Binary file added bank/rannou25696c5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added filters/denoise
Empty file.
Empty file added filters/rotate
Empty file.
Empty file added filters/sepia
Empty file.
10 changes: 7 additions & 3 deletions registeredarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
$('#fileTreeDemo_1').fileTree({ root: full2, script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
openFile(file)
;}) ;});
$(document).ready( function() {
$('#fileTreeDemo_2').fileTree({ root: '../../filters/', script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
preview(file)
;}) ;});
</script>

<style>
Expand Down Expand Up @@ -111,14 +115,14 @@
<tr>
<td>Your images</td>
<td>Preview</td>
<td>Filter</td>
<td>Filters</td>
<td>Filtered image</td>
</tr>
<tr>
<td><div id="fileTreeDemo_1" class="demo"></div></td>
<td><div id="preview"></div></td>
<td>row 2, cell 3</td>
<td>row 2, cell 4</td>
<td><div id="fileTreeDemo_2" class="demo"></div></td>
<td><div id="filtered"></div></td>
</tr>
<tr>
<td> <form enctype="multipart/form-data" action="upload.php" method="POST">
Expand Down
12 changes: 12 additions & 0 deletions upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$target = "bank/rannou/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>

0 comments on commit 6f8f364

Please sign in to comment.