i successfully did it using the jquery forms plugin. this means it sent the whole path from which i got the the file name and printed it out. THANKS TO YOU VIC, there is no way i c'd have done this without this kind of help.
here is the javascript.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
// prepare the form when the DOM is ready
$(document).ready(function() {
// bind form using ajaxForm
$('#htmlForm').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#htmlExampleTarget',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#htmlExampleTarget').fadeIn('slow');
}
});
});
</script>
and here is the html
<form id="htmlForm" action="file.php" method="post">
Message: <input type="text" name="message" value="Hello HTML" /> <p></p>
Image : <input type="file" name="image" id="image" /><p></p>
<input type="submit" value="Echo as HTML" />
and here is the php
$image = $_FILES['image']['tmp_name'];
$name = $_FILES['image']['name'];
move_uploaded_file($image, "uploads/".$name);
echo '<div style="background-color:#ffa; padding:20px">' . $_POST['message'] . '</div>';
echo '<img src="uploads/'.$name.'"/>';