I'm trying to upload an Image to PHP. The most common method I found out to do this was using FORM/POST; But that doesn't help me for what I am about to do.
What I actually am trying to do is upload an image to PHP, the PHP Script will perform its processing and returns a path to the processed image or the image itself. I need to handle sending and returned data. I have tried going through numerous image upload scripts and tutorials, which are good for nothin; except for telling me how image processing works.
The following is my code for HTML, Can anyone help me to write the image sending and retrieving in jQuery?
<html>
<head>
<style type="text/css">
#buttonsdiv{
position: relative;
left: 30%;
top: 10%;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js />
<script type="text/javascript">
$(document).ready({
});
function dismissUploader(){
document.getElementById("file").value = "";
}
</script>
</head>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data" >
<label for="file" class="filelabel">Select an Image</label><BR />
<input type="file" name="image" id="file" class="fileupload" size="30"><BR />
<div id="buttonsdiv">
<input type="submit" name="upload" class="upload" id="upload" value="Upload" />
<input type="button" name="close" class="cancel" value="Cancel" onclick="javascript:dismissUploader();" />
</div>
</form>
</body>
</html>
and for the sake of argument, lets assume that the upload file is something like this
<?php
if (isset($_POST["upload"]))
{
$result= "c:\usr\tmp\123.jpg";
return $result;
}else{
die("error");
}
?>
What happens now is When the user uploads the file, the file is then posted to a file called "upload.php" which returns the uploaded path of the file.
I wanted to know wether if there is any way to get that path from PHP? or Do I need to use jQuery to POST and recieve the path?